الجمعة، 28 مايو 2010

Linux Networking Configuring Multiple IP Addresses

Configuring Multiple IP Addresses E-mail

Configuring Multiple IP Addresses on a single NIC.


In the last section, we have learned to configure IP address for your interface. It is also possible to configure more than one IP addresses on a single NIC example: eth0. For this, we need to create a new child interface with name eth0:X where X can have the values 0, 1, 2, ........


The steps are very similar to the one we explained in the previous section (eth0). You need to verify the following details.

* First ensure the parent real interface (eth0) exists
* Verify that no other IP aliases with the same name exists with the name you plan to use. In this we want to create interface eth0:0.
* Create the virtual interface with the ifconfig command


As we discussed earlier, we shall create the file /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the following contents.


-------------
DEVICE=Interface:X (eth0:0)
ONBOOT=yes
BOOTPROTO=static
IPADDR=IP_address
NETMASK=NET_MASK
-------------


Once it is done, please use the following commands to activate the interface.


-------------
root@Basil15099/~# ifdown Interface:X
root@Basil15099/~# ifup Interface:X
-------------


In my example, I have created a child interface eth0:0 with the IP address 192.168.1.101. So I had to modify the file /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the following details.

-------------
DEVICE=eth0:0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.169.1.101
NETMASK=255.255.255.0
-------------

Then I executed the following commands to activate my child interface.

-------------
root@Basil15099/~# ifdown eth0:0
root@Basil15099/~# ifup eth0:0
-------------


If you are not using Fedora Linux, please use the following command to configure IP address for your child interface.

-------------
root@Basil15099/~# ifconfig interface:X IP_address netmask NET_MASK up
-------------

As you know this configuration will last till the next reboot. So in order to make the configuration permanent, you need to put the above command in the /etc/rc.local file.

So in my example, the command will be as follows.

-------------
root@Basil15099/~# ifconfig eth0:0 192.169.1.101 netmask 255.255.255.0 up
-------------


Thats all :-)

ليست هناك تعليقات:

إرسال تعليق