[olug] Two IP addresses for one nmcli command?

Matthew G. Marsh olug4mgm at paktronix.com
Tue Jun 15 08:05:09 CDT 2021


Copying my answer from the Discord list for reference:

---inc---

Assuming that 10.1.0.14 is the PRIMARY address - then 'ip' strongly 
prefers that SECONDARY addresses do NOT have any netmask other than /32 - 
The only time to not use /32 on a "secondary" address is when the address 
is NOT in any of the other address's CIDR space. Essentially there is no 
concept of Primary vs. Secondary addresses with respect to 'ip' command. 
All addresses are independent. Thus when assigning more than one address 
to a specific address you should take care to only have one "primary" 
address within any given CIDR space. Sense?

BTW - Addendum - just read the OLUG list post. I do not have any clue how 
'nmcli' works. My response above is solely based on the way Linux 
implements addressing in the kernel. I suspect from your OLUG post that 
unless 'nmcli' is specifically told to override some type of default 
setting that anything 'add' to an existing interface is automatically 
secondary with the default setting as primary. But that is just a guess.

---end---

HTH!

mgm

On Mon, 14 Jun 2021, Dave Thacker wrote:

> Centos 8 on a VMware VM.
>
> I'm practicing my nmcli-fu for the exam.   I created an "extra" virtual NIC
> on the VM.   It shows up as device ens161. I used nmcli like this:
>
> nmcli connection add ifname ens161 ipv4.10.1.21.60/16 ipv4.gateway 10.1.1.1
> ipv4.dns 8.8.8.8 type ethernet
>
> I got an extra dynamic address and my requested address is secondary.   It
> still works, but I'm curious how this happened.  I also wonder if RH will
> think this is a good answer.
>
> ens161: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group
> default qlen 1000
>   inet 10.1.0.14/16 brd 10.1.255.255 scope global dynamic noprefixroute ens161
>
>   inet 10.1.21.60/16 brd 10.1.255.255 scope global secondary noprefixroute
> ens161
>
> Dave
> -- 
> Dave Thacker

--------------------------------------------------
Matthew G. Marsh
Special Email Addr for OLUG ;-}
Phone: (402) 932-7250
Email: olug4mgm at paktronix.com
WWW:  http://www.paksecured.org
--------------------------------------------------


More information about the OLUG mailing list