Home > Uncategorized > Linux: HOWTO add an additional IP address to an interface

Linux: HOWTO add an additional IP address to an interface

Works for:
Red Hat Entperise Linux, Oracle Linux, CentOS or any other Red Hat based distribution

HOWTO:
You can bind multiple IP addresses to one interface. Just go to your /etc/sysconfig/network-scripts directory and copy your existing interface configuration file to an additional one:

[root@linux01 ~]# cd /etc/sysconfig/network-scripts/
[root@linux01 network-scripts]# ls -al ifcfg-eth0 
-rw-r--r-- 1 root root 201 Dec 30  2009 ifcfg-eth0
[root@linux01 network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[root@linux01 network-scripts]#

Now adapt your newly create configuration file (DEVICE, remove HWADDR, adapt network information, etc.). Example:

[root@linux01 network-scripts]# cat ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=static
BROADCAST=192.168.2.255
IPADDR=192.168.2.233
NETMASK=255.255.255.0
NETWORK=192.168.2.0
ONBOOT=yes
[root@linux01 network-scripts]#

Either use ifup or restart the network service to update the interface configuration:

[root@linux01 network-scripts]# service network restart
Shutting down interface eth0:                              [  OK  ]
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:                                [  OK  ]
[root@linux01 network-scripts]#

Check the status of your newly created “virtual” interface:

[root@linux01 network-scripts]# ifconfig eth0:1
eth0:1    Link encap:Ethernet  HWaddr 00:0A:2A:4A:EA:4A 
          inet addr:192.168.2.233  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:59 Base address:0x2024 
 
[root@linux01 network-scripts]#
Categories: Uncategorized Tags:
  1. No comments yet.
  1. No trackbacks yet.

Connect with Facebook