This is for the configuration of IP alias on CentOS 7.
The server IP is 5.135.151.44
The IP alias is 176.31.176.61
The changes will be made at:
/etc/sysconfig/network-scripts/ We will first look to copy the current interface of "ifcfg-eth0" with: sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0 The new interface will be known as eth0:0
I prefer to use nano as my editing tool. By default CentOS doesn't install it. We will install it manually with:
yum install nano Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.bbln.org * extras: centos.mirrors.ovh.net * updates: centos.mirrors.ovh.net Resolving Dependencies --> Running transaction check ---> Package nano.x86_64 0:2.3.1-10.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: nano x86_64 2.3.1-10.el7 base 440 k Transaction Summary ================================================================================ Install 1 Package Total download size: 440 k Installed size: 1.6 M Is this ok [y/d/N]: y Downloading packages: nano-2.3.1-10.el7.x86_64.rpm | 440 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : nano-2.3.1-10.el7.x86_64 1/1 Verifying : nano-2.3.1-10.el7.x86_64 1/1 Installed: nano.x86_64 0:2.3.1-10.el7 Complete!
Now we edit the file eth0:0, it will have the following content
DEVICE="eth0:0" BOOTPROTO="static" IPADDR="176.31.176.61" ONBOOT="yes" BROADCAST="176.31.176.61"
To enable the interface we will use ifup eth0:0
This will give us the following ifconfig:
eth0: flags=4163mtu 1500 inet 5.135.151.44 netmask 255.255.252.0 broadcast 5.135.151.255 inet6 fe80::250:56ff:fe01:929 prefixlen 64 scopeid 0x20 ether 00:50:56:01:09:29 txqueuelen 1000 (Ethernet) RX packets 12383 bytes 963676 (941.0 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 322 bytes 35753 (34.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eth0:0: flags=4163 mtu 1500 inet 176.31.176.61 netmask 255.255.0.0 broadcast 176.31.176.61 ether 00:50:56:01:09:29 txqueuelen 1000 (Ethernet) lo: flags=73 mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10 loop txqueuelen 0 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
There appears to be an issue upon rebooting the server as eth0:0 doesn't come back up. At the moment we would issue the command ifup eth0:0 upon rebooting the server.