To permanently add one or more IP's to network interface in RedHat Linux is quite easy if you follow this steps:
- Go to the /etc/sysconfig/network-scripts/ directory
cd /etc/sysconfig/network-scripts/
- Copy the interface file that you want to add the IP to, and give it the same name as the current file, with ‘:0′ added (or :1, :2, depending on how many IPs are on this interface).
cp ifcfg-eth0 ifcfg-eth0:0
- Edit the new file, and you only have to change a few things
> Change IPADDR= to your new IP address
> Change DEVICE= to add :0
(depending if this is the 2nd IP on that interface)
> Remove DHCP_HOSTNAME (or set it to what it needs to be)
> remove the HWADDR entry
- Save the file that you just were working on
- Restart the network interfaces
/etc/init.d/network restart
- Done!
So here are the examples:
Original file ifcfg-eth0 looks like
# Intel Corporation 82557/8/9 [Ethernet Pro 100]
DEVICE=eth0
BOOTPROTO=none
BROADCAST=192.168.5.255
HWADDR=00:06:5B:38:C8:5D
IPADDR=192.168.5.230
NETMASK=255.255.255.0
NETWORK=192.168.5.0
ONBOOT=yes
GATEWAY=192.168.5.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
Config file ifcfg-eth0:0 for second IP looks like:
DEVICE=eth0:0
BOOTPROTO=none
BROADCAST=192.168.5.255
IPADDR=192.168.5.20
NETMASK=255.255.255.0
NETWORK=192.168.5.0
GATEWAY=192.168.5.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
ONPARENT=yes
3530a2b3-2b05-4971-8cb5-2d8a590cd2a4|0|.0