Bind Multiple IPs To One Physical Interface on Linux

In advanced computing you may encounter situations where you want to bind multiple IP addresses on one physical network interface. This post describes how to do it with Ubuntu Linux (should work with Debian too).

Temporarily with ifconfig

This method is temporary only as the additional IP address will be gone after a reboot.

Setup the alias eth0:0 for eth0:

ifconfig eth0:0 192.168.1.11 netmask 255.255.255.0 up

Remove the alias again:

ifconfig eth0:0 down

(The command ifconfig eth0:0 plumb and its counterpart ... unplumb both seem do be not needed with Ubuntu 10.10 in order to create the alias on the NIC.)

Temporarily with ip addr

This method is temporary only as the additional IP address will be gone after a reboot.

# With label `:0` :
ip addr add 192.168.100.199/24 brd + dev eth0 label eth0:0

# or without label:
ip addr add 192.168.100.199/24 dev eth0
# down
ip addr del 192.168.100.199/24 dev eth0

At Every Startup with /etc/network/interfaces

Setup the alias interface using the following additional lines in /etc/network/interfaces:

auto eth0:0
iface eth0:0 inet static
  address 192.168.1.11
  netmask 255.255.255.0

Don't forget to restart networking in order to activate your new settings: sudo /etc/init.d/networking restart

Resources

Comments