How to bind secondary IP addresses in Debian Server.

There is slight difference in binding secondary IP addresses in Debian server to that of a Redhat Linux server.

Open file /etc/network/interfaces
Contents of the file looks like

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.xyx
gateway 192.168.0.1

Suppose we wants to add an IP 192.168.0.3 add the following to /etc/network/interfaces.

auto eth0:1
iface eth0:1 inet static
address 192.168.0.3
netmask 255.255.255.xyx
gateway 192.168.0.1

Now run the command

ifup eth0:1

This will add Ip 192.168.0.3 in ifconfig output.

To add next secondary IP the next set of entry should be

auto eth0:2
iface eth0:2 inet static
address 192.168.0.4
netmask 255.255.255.xyx
gateway 192.168.0.1

Then Run

ifup eth0:2

These IP addresses are bounded to eth0 that is to the first NIC.
If you wants to bind the IP to the second network card the entry should be eth1:1 instead of eth0:1

Finally check whether the IP addresses are listed in the ifconfig output.

Trackback URI | Comments RSS

Leave a Reply

You must be logged in to post a comment.