eth0:1 aliases in NM, manual setup

Thomas Haller thaller at redhat.com
Mon Jul 22 09:59:18 UTC 2024


On Mon, 2024-07-22 at 12:45 +0300, Andrei Borzenkov wrote:
> On Mon, Jul 22, 2024 at 11:17 AM Íñigo Huguet <ihuguet at redhat.com>
> wrote:
> 
> 
> AFAIU kernel considers the very first interface address for a given
> subnet/scope as primary and all addresses for the same combination of
> subnet/scope added later as secondary. So, to keep the specific
> address as primary it has to be configured first. I suspect legacy
> scripts implicitly processed ifcfg-ethX before ifcfg-ethX:N, so
> address in ifcfg-ethX became primary.
> 
> Does NetworkManager process ipv4.addresses in deterministic order?
> Can
> we rely that for "ipv4.addresses A1 A2 A3" it will always add A1
> first, then A2, then A3? Especially with DHCP where there could be
> delay waiting for completion of the DHCP transaction.
> 

Hi,

It works.

Addresses can become ready for configuration in any order. For example,
if you do DAD/ACD. Or if you do `nmcli device modify DEV ipv4.addresses
ADDRS`.

When NetworkManager notices that the order is not as required, it will
delete and re-add them in the right order.


The complexity of getting that right, is considerable. It's here:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/777418dfd786722d4dc16d4e60d2ca724f93b55c/src/libnm-platform/nm-platform.c#L4327


Note that for IPv4, a conflict only exists (and a meaningful concept of
"primary") for addresses in the same subnet. For IPv6, it's only
meaningful between addresses in the same scope. That corresponds to how
kernel treats it.


Thomas



More information about the Networkmanager mailing list