How to Add IP Address on CentOS Operating Systems?
To add a new IP into your environment you firstly need to locate network configuration directory. To access it use:
To add new IP first you need to copy ifcfg-eth0 file by creating new file ifcfg-eth0:0. Use following command:
cp ifcfg-eth0 ifcfg-eth0:0
Now it’s time to edit the file you’ve copied. Enter:
This command will open the file with Linux text editor (if you prefer another text editor you can choose nano). Look at the lines which should be in the file and the changes which should be applied:
DEVICE=”eth0″ change into DEVICE=”eth0:0″
IPADDR= 184.108.40.206 contains the IP which you want to add
NETMASK=255.255.255.0 for example if you have IP from /24 subnet then netmask will be 255.255.255.0
GATEWAY=220.127.116.11 also include the gateway
To save the changes enter:
Make sure that all configurations are correct and after adding required IP restart the network by using the following command:
That’s it. You’ve added a new IP address to your server with CentOS.