To add static IP – Single IP
Create/edit file named ifcfg-<interface> in /etc/sysconfig/network-scripts/
How to get Interface Information?
Usually, the interface will be eth0. It can be determined from ifconfig result. Interface is the name under which new IP will be added.
Add the following details :
DEVICE="interface name to which IP is to be added" BOOTPROTO="static" ONBOOT="yes" IPADDR="IP address to be added" NETMASK="netmask"
Eg: to add IP 111.92.64.16 as a static IP to eth0:1
DEVICE=”eth0:1″
BOOTPROTO=”static”
ONBOOT=”yes”
IPADDR=”111.92.64.16″
NETMASK=’255.255.255.0″
Then restart the network service or start the interface :
/etc/init.d/network restart
or
service network restart
or
Start the interface
ifup eth0:1
Using setup command
There is a command “setup” which can do this.
1. Run “setup” as root user.
2. Select “Network Configuration” and click “Run Tool”.
3. Select “New Device” and provide the details. Click ok to save.
4. Restart network service.
To add IP range
Create/edit file named ifcfg-<interface>-range0 in /etc/sysconfig/network-scripts/
Add the following details :
IPADDR_START="starting IP" IPADDR_END='ending IP" CLONENUM_START="starting number assigned to virtual interface" NETMASK='netmask"
Eg: To add IPs 10.10.2.1 to 20.10.2.254
IPADDR_START=”10.10.2.1″
IPADDR_END=’20.10.2.254″
CLONENUM_START=”0″
BOOTPROTO=’static”
ONBOOT=”yes”
This binds the IP 10.10.2.1 to eth0:0 and 10.10.2.1 to eth0:1 and so on.
Then restart the network service or start the interface :
/etc/init.d/network restart
OR
service network restart