lundi 7 janvier 2008

Configuring Multiple IP Addresses for Ubuntu Linux

There are times when you may want to add a second or multiple IP addresses to your linux system. It’s fairly straightforward to add a sub-interface to your current configuration. In fact, it’s just as easy to add ten sub-interfaces as it is one.


Start by opening a console with root permissions.

configuring_multiple_ip_addresses_for_ubuntu_linux0.png

Next we edit the interfaces configuration file.

# nano /etc/network/interfaces

configuring_multiple_ip_addresses_for_ubuntu_linux1.png

Within the interfaces file, you should see a section that contains IP information for your current network interface cards.

configuring_multiple_ip_addresses_for_ubuntu_linux2.png

My primary interface in this example is “eth0″. If I want to add another ip address to that interface I would start by defining it. For example add a line like the following and modify it to match your setup.

auto eth0:1

Notice that it is named the same as my original “eth0″ but also has “:1″ appended to it.

configuring_multiple_ip_addresses_for_ubuntu_linux3.png

Below that line add the following line. Again, modifying the interface name to match your configuration.

iface eth0:1 inet static

configuring_multiple_ip_addresses_for_ubuntu_linux4.png

Next you need to add the IP addressing information. I’ve used the following.

address 172.17.2.10

netmask 255.255.0.0

network 172.17.0.0

broadcast 172.17.255.255

gateway 172.17.1.1

configuring_multiple_ip_addresses_for_ubuntu_linux5.png

Press “ctrl-x” to exit nano editor. Press “y” to save modifications.

configuring_multiple_ip_addresses_for_ubuntu_linux6.png

Accept the default save path.

configuring_multiple_ip_addresses_for_ubuntu_linux7.png

configuring_multiple_ip_addresses_for_ubuntu_linux8.png

Next, we need to restart the network service.

# /etc/init.d/networking restart

configuring_multiple_ip_addresses_for_ubuntu_linux9.png

Be alert for any errors when restarting the network. This will indicate a possible typo in the configuration if you get an error.

configuring_multiple_ip_addresses_for_ubuntu_linux10.png

Let’s view the new sub-interface we created.

# ifconfig eth0:1

configuring_multiple_ip_addresses_for_ubuntu_linux11.png

All the settings seem to have taken effect…

configuring_multiple_ip_addresses_for_ubuntu_linux12.png

Next we’ll ping the interface to test it.

# ping 172.17.2.10

configuring_multiple_ip_addresses_for_ubuntu_linux13.png

Successful ping requests are always a good sign. At this point you may want to try to ping another IP address on the same subnet as your new interface. I’ll leave that part in your capable hands. :)

configuring_multiple_ip_addresses_for_ubuntu_linux14.png

We’re all done here, so I’ll log off as root.

# exit

configuring_multiple_ip_addresses_for_ubuntu_linux15.png

Aucun commentaire: