NetworkManager spontaneously changes dynamic IP address once daily

Hi!

I have an installation of openSUSE 15.4 with NetworkManager. It is configured with a dynamic IP address. I noticed that every 1 or 2 days NetworkManager for some reason changes the assigned IP address. If the computer has been left up for more than 24 hours, then the IP address changes during a session. This causes my ssh connections to freeze and time out. I would like to find out how to stop the dynamic IP address from changing spontaneously. The installation is a desktop computer with wired ethernet.

This is what I find in the log file after the IP change happens:

2024-03-04T10:08:56.981665-08:00 venere avahi-daemon[684]: Withdrawing address record for 192.168.1.112 on eth1.
2024-03-04T10:08:56.981791-08:00 venere avahi-daemon[684]: Leaving mDNS multicast group on interface eth1.IPv4 with address 192.168.1.112.
2024-03-04T10:08:57.058001-08:00 venere avahi-daemon[684]: Interface eth1.IPv4 no longer relevant for mDNS.
2024-03-04T10:08:57.058213-08:00 venere avahi-daemon[684]: Joining mDNS multicast group on interface eth1.IPv4 with address 192.168.1.128.
2024-03-04T10:08:57.140039-08:00 venere avahi-daemon[684]: New relevant interface eth1.IPv4 for mDNS.
2024-03-04T10:08:57.140173-08:00 venere avahi-daemon[684]: Registering new address record for 192.168.1.128 on eth1.IPv4.
2024-03-04T10:08:57.169931-08:00 venere dbus-daemon[685]: [system] Activating via systemd: service name='org.freedesktop.nm_dispatcher' unit='dbus-org.freedesktop.nm-dispatcher.service' requested by ':1.4' (uid=0 pid=686 comm="/usr/sbin/NetworkManager --no-daemon ")
2024-03-04T10:08:57.210522-08:00 venere systemd[1]: Starting Network Manager Script Dispatcher Service...
2024-03-04T10:08:57.362555-08:00 venere dbus-daemon[685]: [system] Successfully activated service 'org.freedesktop.nm_dispatcher'
2024-03-04T10:08:57.363880-08:00 venere systemd[1]: Started Network Manager Script Dispatcher Service.
2024-03-04T10:09:08.420640-08:00 venere systemd[1]: NetworkManager-dispatcher.service: Deactivated successfully.

Is there a particular parameter that I can adjust to avoid this?

Thanks!

Your DHCP Server has a configuration called Lease Duration and it may have the time set to short.

I am using a Linksys router. In the Setup for DHCP it says:

Client Lease Time: 0 minutes (0 means one day)

But I am confused. I have a openSUSE 15.2 installation on a laptop also with NetworkManager and dynamic IP. There, I get the exact same IP address day after day. So, what changed between openSUSE 15.2 and openSUSE 15.4? Why is NetworkManager in 15.4 checking the lease of the IP address and asking for a new one while the system is up and running? Why can’t it just keep the same dynamic IP address?

Thanks!

I’m assuming the mac addr in the client list of the router is the same across the ip assignments? Maybe some difference in the result of a command like:

nmcli con show myconnectionname |grep -i client

between the two PCs where “myconnectionname” is the name shown in something like

nmcli con

I’m assuming the mac addr in the client list of the router is the same across the ip assignments?

I assume that the MAC address of my desktop network card stays the same every day. Why would that change? I can find that with ip addr show. Maybe I’ll check tomorrow again to see whether it changes.

nmcli con returns:

NAME UUID TYPE DEVICE
Wired connection 1 … ethernet eth1
eth0 … ethernet –

I replaced the numbers with “…” to keep them private.

nmcli con show "Wired connection 1" | grep -i client

ipv4.dhcp-client-id: –

nmcli con show eth0 | grep -i client

ipv4.dhcp-client-id: –

I probably should let someone using your version comment. I see a result like:
ipv4.dhcp-client-id: –
ipv4.dhcp-client-id: –
DHCP4.OPTION[2]: dhcp_client_identifier = my mac address

I was expecting a client identifier result. I would think unless the show command has some mac address mask setting and the client identifier is the mac address you’d be getting the same ip.

I believe the syntax to set the id and hostname looks something like:

nmcli con modify myconnectionname ipv4.dhcp-client-id my:mac:addr:here:

but you may wish to double-check this

Are you saying that in my case the mac address is somehow masked and not communicated to the Linksys router?

I do see in the DHCP client table of the Linksys router that the MAC address of my PC is listed with the corresponding IP address assigned right now.

Or, are you saying that the MAC address just needs to show up in nmcli con "NAME" in order to get the same IP address?

You could always use the Reserve IP Address function in your router to assign the same IP address to the client MAC every time you connect. I find that very useful for internal maintenance and connections between the devices on my private network.

1 Like

Thanks! I noticed that. But I still would like to understand why there is a difference between the two systems.

At some point, I used nmcli to add a domain name search with:

nmcli con mod “Wired connection 1” ipv4.dns-search “my domain”

I think that after that it started having the problem of changing IP address daily. Maybe by adding the domain search name the client-id got erased?

Are the nmcli options saved somewhere so I can make a backup before I change anything else?

Thanks!

I just checked the configuration in my laptop with openSUSE 15.2. There I also do not see the MAC address in nmcli con show "Wired connection 1". And yet, even after a few days of not using that laptop it still uses the exact same IP address. Something must have changed between the two distributions or by me by adding the domain search name.

Leap 15.2 is dead as dead can be. Just saying.

2 Likes

OK, but this is a comparison. Why did it work differently in the past? Or, is it something that I have done?

I have no idea what changed. To have the same IP all the time you need a static IP address. And a gateway IP and DNS’s.

1 Like

This is a home router from which I get a dynamic IP.

What desktop are you using?

I am using the trinity desktop environment (TDE).

Reboot, wait untli the address changes, as root capture complete logs with

journalctl -b --no-pager --full

upload logs to https://paste.opensuse.org/

Thanks. I’m doing this now. I rebooted and waiting for the address to change.

How many machines do you have on your LAN?
I’m assuming you’ve restarted your router.
Do you know the address range your DHCP server assigns?
Personally, if a LAN has 20 or less network attached devices, I statically assign the local machines a static IP and eliminate all similar headaches.

1 Like

The PC has been up for four days and I have still not seen the behavior where it changes the dynamic IP address. It is possible that the past observation where the dynamic IP changed was due to a service interruption from my internet service provider (ISP) and for some reason the OS (dhcp client or NetworkManager) decided to ask for a different address from the router. This is still strange because the dhcp client normally should ask for the same IP address it had before. There is a file that lists all the leased IP addresses:

/var/lib/NetworkManager/dhclient-<identifier>-eth1.lease

<identifier> is a long hexadecimjal string. My understanding is that whenever you reconnect to the same router the OS (dhcp or NetworkManager) requests the same IP address as in the last lease, besides the fact that the router also reserves a specific IP address for the same MAC address for a set period of time (in the case of my router this is 1 day). Is there maybe a setting somewhere that instructs dhcp/NetworkManager to ask for a different IP address whenever there is an internet service interruption? The file: /etc/NetworkManager lists:

[connectivity]
uri=http://conncheck.opensuse.org

meaning that it periodically checks connectivity to the above website and asks for a new IP address if not able to connect?

In any case, if this keeps happening I will either assign a static IP or instruct the router to reserve a dynamic IP address for the MAC address of the network card. I just want to understand why the IP address change happens or happened with the current installation. I will post the log if I observe again the address change.