Tag Archives: debian

Binding IP’s to NICs in Debian

So, say you want one of your Debian based servers to listen on more than 1 IP address. Heres a quick and dirty example of how to do this.

This may or may not be the correct way to do this, but it works on my machines.

Adding an IP to eth0 (usually the default)

If you look in your /etc/network/interfaces file you should see something like this:

auto eth0
iface eth0 inet static
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254

That is your standard IP address bound to the network card eth0. To add another IP address on the same subnet, add something like the following below the above stanza.

auto eth0:0
iface eth0:0 inet static
address 192.168.0.128
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254

At this point I just reboot to activate the new IP(s) but I am sure you can just do an ‘ifconfig eth0:0 up’ with all the pertinent info there.