Centos 6 / 7
CentOS works with an interface file per physical connection. You can find the interface files in: /etc/sysconfig/network-scripts/ifcfg-xx. Where xx is the name of the interface. If your interface is called eth0, we will create a file for eth0:1. We recommend to use ‘nano’ to edit the file:
nano /etc/sysconfig/network-scripts/ifcfg-eth0:1 |
Copy all the text below and add this to the opened file, adjust the highlighted so it fits your situation:
DEVICE=eth0:1 ONBOOT=yes BOOTPROTO=static IPADDR=192.168.1.51 NETMASK=255.255.255.0 |
Note: the device is called eth0:1, while the file is also called eth0:1. This is intentional. When you exit the text editor you can apply the changes by using the following command:
ifup eth0:1 |
Should you want to add more static addresses you can follow the logic and add the next static IP on eth0:2.
If you are unsure if your configuration is correct feel free to contact us here.