This will show you how to bind more IP into a server



$ sudo nano /etc/network/interfaces

Append or modify file as follows:
auto eth0
auto eth0:0
auto eth0:1
 
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.254
 
iface eth0:0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.254
 
iface eth0:1 inet static
address 192.168.1.3
netmask 255.255.255.0
gateway 192.168.1.254
 
# add rest of alias / binds below
 

 

A Note About Configuration Using ip Command

The ifconfig command is being phased out and being replaced by the ip command. The newer ip command does not use the same concept of aliases or virtual interfaces and instead treats additional addresses as first class objects. The newer way to configure multiple addresses on one interface is to use the up and down mechanism to call ip at the correct times to add and remove these additional IP addresses. Sample This /etc/network/interfaces file which assigns two IP addresses to eth0 and assigns labels to them:
 
auto eth0
allow-hotplug eth0
iface eth0 inet static
    address 192.168.1.1
    netmask 255.255.255.0
    gateway 192.168.1.254
    up   ip addr add 192.168.1.2/24 dev eth0 label eth0:0
    down ip addr del 192.168.1.2/24 dev eth0 label eth0:0
    up   ip addr add 192.168.1.3/24 dev eth0 label eth0:1
    down ip addr del 192.168.1.3/24 dev eth0 label eth0:1
 
Save and close the file. Restart networking service under Debian / Ubuntu Linux, enter:

# /etc/init.d/networking restart
OR

$ sudo /etc/init.d/networking restart

 

How Do I Verify New Settings?

To verify your new settings, type:

# ifconfig -a
OR

# ip addr show eth0
Sample outputs:
2: eth0:  mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:ac:6f:65:31:e5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.1/24 brd 192.168.1.255 scope global eth0
    inet 192.168.1.2/24 scope global secondary eth0:0
    inet 192.168.1.3/24 scope global secondary eth0:1
    inet6 fe80::baac:6fff:fe65:31e5/64 scope link
       valid_lft forever preferred_lft forever

Leave a Reply