Sunday, August 24, 2008

How to bind additional IPs in Debian / Ubuntu Linux

So you're looking to add an additional IP addresses to a network interface that already has an IP address bound to it? Here's how: (source: NixCraft Article)

Let us assume that your eth0 IP address is 192.168.1.1. You need to create alias or binding using eth0:0, eth0:1...eth0:N devices. You need to add range of IP's in /etc/network/interfaces config file under Debian/Ubuntu Linux. First make a backup of existing file:

$ cp /etc/network/interfaces /root/working.interfaces

Now open file using nano text editor:

$ sudo nano /etc/network/interfaces

Modify as follows:

auto eth0
auto eth0:0
auto eth0:1

iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.248
gateway 192.168.1.254

iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.248
gateway 192.168.1.254

iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.248
gateway 192.168.1.254
# add rest of alias / binds below

Save and close the file.

Now restart networking, enter:

$ sudo /etc/init.d/networking restart

That's all! Thanks NixCraft!

No comments: