Bind Multiple IP Addresses on a Single Network Card IPv4 & IPv6

The beauty of having multiple IP addresses on a single server is that you can run several services with different addressing. This way you can announce your FTP service on a different address and your HTTP on another. Below I’ll describe how to achieve this in Debian based and Red Hat based distros seperately. Using Debian based distros (Ubuntu, Mint etc.), setting multiple IP addresses on a single network interface is simple. What we will do is to edit the /etc/network/interfaces file. If you are using DHCP, then your file should look similar to this,
    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″
  • 93 Users Found This Useful
Was this answer helpful?

Related Articles

Setting time with NTP in LINUX

NTP (Network Time Protocol) could be used to set time synced with ntp clocks, to do this use the...

Linux version & Operating System info

LINUX Version Info To learn the architecture and kernel version info use the shell command...

Build PHP5.5 on CentOS 6.4 with MSSQL Support [cite]

Most of the yum repos doesn’t include PHP5.5.X on current releases for the time being. So...

Change Outgoing IP of Postfix Mail Server

This can get quite important when your mail server is blacklisted, or if you somehow want to...

Add New Hosting to a System Installed With Plugged.sh

If you use our LAMP installer script and want to add a new domain afterwards, we’ve created...