How to add IP address on CentOS
In order to add an additional IP address to your system you will have to create a new eth0 interface file with an additional number in the name and fill it with network information. For example standart file name is ifcfg-eth0 and a new file name should be ifcfg-eth0:1. The file must be put in the directory /etc/sysconfig/network-scripts/.
Step 1 – Simply use your favorite text editor and create a file:
- nano /etc/sysconfig/network-scripts/ifcfg-eth0:1 – remember that the number differs depending on how many additional IP’s you already have. If you have 7 IP’s already and you want to add 8th the file name will be ifcfg-eth0:8
Step 2 – Fill the file with network information. The file should look something like this:
Take note that field DEVICE must be equal to the files name extention. For example if files name is ifcfg-eth0:1 the field DEVICE should be equal to eth0:1.
Step 3 – to active the settings use simple command:
- ifup eth0:1 – Change part eth0:1 depending on which interface file you want to active.