eth0:1 aliases in NM, manual setup

Andrei Borzenkov arvidjaar at gmail.com
Mon Jul 22 09:45:19 UTC 2024


On Mon, Jul 22, 2024 at 11:17 AM Íñigo Huguet <ihuguet at redhat.com> wrote:
>
> Hi Martin.
>
> On Thu, Jul 4, 2024 at 1:19 PM Martin Vogt <mvogt1 at gmail.com> wrote:
> >
> >
> > Hello,
> >
> > I have to migrate a server IP to a new NM managed server, which I setup.
> >
> > The new server has the primary IP cups6 192.168.48.46/24 (ens224) and dhcp on boot.
> > I like to add a manual IP 192.168.48.16  like in the old setup, on cups5:
> >
> > ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
> >        inet 192.168.48.20  netmask 255.255.255.0  broadcast 192.168.48.255
> > ens224:1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
> >        inet 192.168.48.16  netmask 255.255.255.0  broadcast 192.168.48.255
> >
> > ifcfg-ens224:1
> > # cups ontop of cups5
> > DEVICE="ens224:1"
> > BOOTPROTO="static"
> > ONBOOT="manual"
> > IPADDR="192.168.48.16"
> > NETMASK="255.255.255.0"
> >
> > When doing it with NM:
> >
> > nmcli connection modify ens224 +ipv4.addresses 192.168.48.16/24 ipv4.method manual
> > - it reorders the interfaces, ens224:1/192.168.48.16 becomes primary and
> > - 192.168.48.46/24 secondary
> > - both are started auto or manually
> >
> > But it should be:
> >
> > primary: 192.168.48.46/24 with dhcp onboot
> > second: 192.168.48.16 manual / static
>
> Try `nmcli connection modify ens224 ipv4.addresses 192.168.48.16/24
> ipv4.method auto`. This is the way to have DHCP enabled + an
> additional static address. Not sure which one will be the primary, I
> think it'll be the DHCP obtained one. Please try and tell us.
>

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.


More information about the Networkmanager mailing list