[Networkmanager] NetworkManager link local IPv4 address based on last 2 octets of ethernet MAC address

Thomas Haller thaller at redhat.com
Thu Oct 19 12:34:53 UTC 2023


On Thu, 2023-10-19 at 17:48 +0530, manjunatha srinivasan wrote:
> Hi 
> I have 2 following ethernet profiles at /etc/NetworkManager/system-
> connections: 

btw, you can also enable LL additionally with DHCP. Then DHCP is
attempted in the background, while you always have a LL address. See
"ipv4.link-local" setting in `man nm-settings`. That is IMO better than
two profiles.

> One for dynamic ip configuration and other for link local as fallback
> when DHCP server is not reachable. As expected when DHCP server is
> not reachable, fall back IPv4 address happens e.g. 169.254.105.20
> with subnet mask as 255.255.0.0 by the NetworkManager.   
> This particular IP address is always the same which is expected one. 
> Please let me know how this constant IPv4 address is decided by the
> NetworkManager.

IPv4LL is documented by RFC
https://datatracker.ietf.org/doc/html/rfc3927#section-2.1

The code is here:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/blob/94ead251ded1ed7d3a1ea9953f041708daf3787f/src/core/nm-l3-ipv4ll.c#L382

It basically hashes the MAC address and a generation counter.

> Also let me know if there is any configuration option in
> NetworkManager to change last 2 octets (i.e.105.20) represented in
> the decimal value of last 2 values of ethernet MAC hex address.  

The address couldn't be fixed, because there is always the possibility
that another host on your network already picked this address. It falls
back to a retry via the generation counter.

In any case, there is no option in NetworkManager (or RFC) to influence
the IPv4LL address in a more immediate way.

>  
> Ethernet (eth0) method based on DHCP:
> [connection]
> id=my-eth0
> uuid=8466b654-0183-4900-a2d6-26a9e6af275e
> type=ethernet
> autoconnect-priority=1
> interface-name=eth0
> timestamp=1697699281
> 
> [ethernet]
> 
> [ipv4]
> dhcp-timeout=10
> method=auto
> 
> [ipv6]
> addr-gen-mode=stable-privacy
> method=auto
> ra-timeout=10
> 
> [proxy]
> -------------------
> Ethernet (eth0) method based on link-local:
> root at FXR90D5FB72:/etc/NetworkManager/system-connections# cat  rfid-
> ll-eth0.nmconnection
> [connection]
> id=ll-eth0
> uuid=f07f43e6-59c8-428f-bc04-55a0e581e621
> type=ethernet
> interface-name=eth0
> 
> [ethernet]
> 
> [ipv4]
> method=link-local
> 
> [ipv6]
> addr-gen-mode=stable-privacy
> method=auto
> 
> [proxy]
> ------
> 
> When DHCP request fails, the IPv4 address fallback to 
> 
> 
> 
> Thanks & Regards
> Manjunatha Srinivasan N



More information about the Networkmanager mailing list