How do I add a second IP-address in Ubuntu 17.10 like the old days where you could add eth0:1, eth0:2 etc.
I've tried but lots of commands have been deprecated like ifup, ifdown etc. and the network settings doesn't seem to be the same as it used to. I might be wrong here but I can't seem to figure it out.
I have a network card eth0 where I want to add a second IP on the same subnet. If I add eth0:1 to /etc/network/interfaces but I can't seem to get the interface up.
Is there another way to do this permanently?
EDIT:
/etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0:1
iface eth0:1 inet static address 10.100.1.39 netmask 255.255.255.0I've tried to add the information on eth0 too but it doesn't seem to make a difference.
This if the output of ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.100.1.38 netmask 255.255.255.0 broadcast 10.100.1.255 inet6 fe80::215:5dff:fe00:1605 prefixlen 64 scopeid 0x20<link> ether 00:15:5d:00:16:05 txqueuelen 1000 (Ethernet) RX packets 496 bytes 248506 (248.5 KB) RX errors 0 dropped 4 overruns 0 frame 0 TX packets 241 bytes 34934 (34.9 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 9 2 Answers
Turns out in 17.10 you edit your network settings in /etc/netplan/01-netcfg.yaml
All I had to do was add the second IP next to the existing one separated with a comma like this:
network: version: 2 renderer: networkd ethernets: eth0: addresses: [ 10.100.1.38/24, 10.100.1.39/24 ] gateway4: 10.100.1.1Then you run:
# netplan applyHope this helps someone in the future.
3You can do that directly on the commandline, which is not permanent (i.e. reboot-save)
sudo ifconfig eth0:0 10.100.1.40 netmask 255.255.255.0 upor in your /etc/network/interfaces, which is permanent
sudo nano /etc/network/interfacesadd this (or similar) to the existing eth0 block
iface eth0:0 inet static address 10.100.1.40 netmask 255.255.255.0and bring it up with
sudo ifup eth0:0 9