Board index Linux General Stuffs

Moderator: chandranjoy

How to configure/add additional IP addresses in Linux

Postby chandranjoy » Thu Jun 23, 2011 4:23 pm

How to configure/add additional IP address in Linux:

This tutorial will show you how to configure additional IP address on NIC under Red Hat Linux or Fedora Core.

The following procedure uses eth0 as an example for assigning a second TCP/IP address.

Use the following command to add the IP address temporarily:

ifconfig eth0:1 xxx.xxx.xxx.xxx


Where xxx.xxx.xxx.xxx is the actual IP address.
Note that eth0:1 is in case you add only a second IP address. Same way you can add eth0:2, eth0:3 and so on.

To make the changes permanent you will need to add the IP also in the network scripts which are being started on system boot.

1. Verify that your /etc/sysconfig/network-scripts/ifcfg-eth0 file does not have a GATEWAY= parameter in it. If it does, remove it and add that parameter to /etc/sysconfig/network.

2. Copy your /etc/sysconfig/network-scripts/ifcfg-eth0 file to a new file called: /etc/sysconfig/network-scripts/ifcfg-eth0:1
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:1


3. In /etc/sysconfig/network-scripts/ifcfg-eth0:1 change DEVICE=eth0 to DEVICE=eth0:1

4. In /etc/sysconfig/network-scripts/ifcfg-eth0:1 modify IPADDR= to match the additional TCP/IP address you wish to use.

5. Start the secondary interface:
ifup eth0:1



How to add bunch/List of IP Addresses in Linux:

Create a new file /etc/sysconfig/network-scripts/ifcfg-eth0-range0 which should containing something like...
IPADDR_START=xxx.xxx.xxx.1
IPADDR_END=xxx.xxx.xxx.100
CLONENUM_START=1


and do:
ifup eth0:1



Note:

The ip addresses must be in the same subnet as the primary card (i.e. if you create ifcfg-eth0-range0,then use the same subnet as eth0).

Enjoy :)
chandranjoy
Site Admin
 
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to General Stuffs

Who is online

Users browsing this forum: No registered users and 1 guest


cron