auto eth0 iface eth0 inet dhcp auto eth0:0 iface eth0:0 inet dhcp iface eth0:0 inet6 dhcp
Here, the eth0:0 is how we get the secondary IP address on the eth0 device. If you’re using a static IP address instead of DHCP, then your interfaces file should be like,
auto eth0 iface eth0 inet static address 10.20.30.40 netmask 255.255.255.0 network 10.20.30.0 broadcast 10.20.30.255 gateway 10.20.30.1 dns-nameservers 8.8.8.8 iface eth0 inet6 static address 2f00:7300:100::10 netmask 64 auto eth0:0 iface eth0:0 inet static address 10.20.30.41 netmask 255.255.255.0 iface eth0:0 inet6 static address 2f00:7300:100::11 netmask 64
You can add as many as you want, such as eth0:1, eth0:2 … Sometimes when adding multiple IPv6 addresses on Debian systems, it is possible that you get an error. The current workaround for that is to enable and disable the device a couple of times. You can find the solution to that problem here. In Red Hat based distros (CentOS, Fedora etc.), the interfaces are edited through the directory /etc/sysconfig/network-scritps. Here we have multiple files, each pointing for a device. For instance, to have 2 additional IP’s on a single ethernet device (totaling 3 addresses) we should have 3 files as follows, /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1 /etc/sysconfig/network-scripts/ifcfg-eth0:2 The main device file would be just a standard one, we don’t have to change anything with it. On the other hand, the ifcfg-eth0:1 file should be similar to this,
NAME=”" BOOTPROTO=static MACADDR=”" IPV6INIT=no DEVICE=eth0:1 NETMASK=255.255.255.0 MTU=”" BROADCAST=10.20.30.255 ONPARENT=yes IPADDR=10.20.30.41 NETWORK=10.20.30.0 IPV6INIT=yes IPV6ADDR=2f00:7300:100::11 IPV6_DEFAULTGW=2f00:7300:100::1 ONBOOT=yes
This would suffice. Don’t forget to restart your network services after adding the lines (or files) to with your appropriate settings. For Debian : $ /etc/init.d/networking stop && /etc/init.d/networking start For Red Hat : $ service network restart For additional IPv6 addresses you should need to add IPV6ADDR_SECONDARIES=”" line to /etc/sysconfig/network-scripts/ifcfg-eth0 file
IPV6INIT=yes IPV6ADDR=2f00:7300:1::2/64 IPV6ADDR_SECONDARIES=”2f00:7300:1::3/64 2f00:7300:1::4/64 2f00:7300:1::fff4/64 2f00:7300:1::fff5/64″