How to add interface alias on RHEL6 or CentOS6 with NetworkManager?

Antoni Sawicki asked:

How to add a network interface alias (for example eth0:0) on CentOS6 or RHEL6 in the “correct” way that is through NetworkManager without NM_CONTROLLED=no. And this has to be done without GUI.

Thank you,
a

My answer:


NetworkManager has only a very basic CLI nmcli which, unfortunately, is not capable of creating connections at this time (but can bring them up and down).

If you need to configure a machine without a GUI it’s strongly recommended you use the normal (non-NM) method as described in the documentation and do not use NetworkManager at all. I will note that you haven’t actually given a reason to use NetworkManager on this system, so I have to recommend against it.

If you really have to do this, the NetworkManager way on Red Hat-derived systems is to add all of the IP addresses to the same /etc/sysconfig/network-scripts/ifcfg-eth0 file. This was described in the NetworkManager documentation under Device Aliases.

Example:

IPADDR=172.25.33.1
PREFIX=29
IPADDR2=172.25.33.2
PREFIX2=29
IPADDR3=172.25.33.3
PREFIX3=29
IPADDR4=172.25.33.4
PREFIX4=29
IPADDR5=172.25.33.5
PREFIX5=29

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.