Network address aliases with NetworkManager

Everyone knows I don’t like NetworkManager, but that doesn’t mean I don’t think it’s worth learning how to make it do my bidding. For example, the simple task of adding an alias address to a network interface.

As I’ve show in previous posts, adding an IP address to an existing network interface is pretty simple under the old network.service using the cp command, a text editor and the ifconfig utility. But what is the least painful way of doing the same thing with that infernal NetworkManager?

It turns out to actually be pretty simple, but does require a small attitude adjustment. The cp command and a text editor are still required, but instead of the venerable ifconfig (which on some platforms has been in the process of being deprecated for the last decade) you’ll need the ip command.

Here’s a typical ifcfg script created by via the NetworkManager gui:


To add an IP alias, say, to this same interface all you have to do is add new IPADDR1, PREFIX1 and GATEWAY1 values. For example:


Once that’s done you should restart NetworkManager to make the change effective.

Although the new IP will ping just find, if you run ifconfig you won’t be able to see it. That’s because the Linux version of ifconfig can’t show more than one IP address per interface. If you use the command “ip addr show” or, with more precision, “ip addr show p5p1”, you’ll see something like this:

[root@test1 ~]# ip addr show p5p1
2: p5p1:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether e3:3d:6a:16:1c:6b brd ff:ff:ff:ff:ff:ff
    inet brd scope global p5p1
       valid_lft forever preferred_lft forever
    inet brd scope global secondary p5p1
       valid_lft forever preferred_lft forever
    inet6 fe80::d63d:7eff:fe16:2b7a/64 scope link 
       valid_lft forever preferred_lft forever

Knowing how to do this really comes in handy is when running Linux on a laptop, where dynamically configured interfaces for both wired and wireless connections (especially those using WPA security) make doing things the old network.service impractical.

This entry was posted in System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).