LXC losing IP address periodically

marcus.cps

New Member
Nov 22, 2023
13
16
3
Apparently my LXC is not renewing DHCP leases.
From time to time the IP address gets released and `eth0@if9` loses the IP. I can't figure out why.

I've seen similar posts and have been trying to fix it with no success.

I used to have 3 network interfaces set in the Proxmox UI, but recently deleted 2 of them kept only one.
Not sure if that's related, though.

LXC Info:

Code:
root@docker:~# uname -a
Linux docker 6.8.12-9-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.12-9 (2025-03-16T19:18Z) x86_64 GNU/Linux

Code:
root@docker:~# ip addr
...
2: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d0:c0:00:00:00:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0
...

Code:
root@docker:~# systemctl status networking.service
* networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; enabled; preset: enabled)
     Active: active (exited) since Thu 2025-04-03 15:09:51 BST; 24h ago
       Docs: man:interfaces(5)
    Process: 4066 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=0/SUCCESS)
    Process: 4088 ExecStart=/bin/sh -c if [ -f /run/network/restart-hotplug ]; then /sbin/ifup -a --read-environment --allow=hotplug;>
   Main PID: 4088 (code=exited, status=0/SUCCESS)
        CPU: 52ms

Apr 03 15:09:51 docker systemd[1]: Starting networking.service - Raise network interfaces...
Apr 03 15:09:51 docker systemd[1]: Finished networking.service - Raise network interfaces.

Code:
root@docker:~# networkctl
IDX LINK            TYPE     OPERATIONAL SETUP  
  1 lo              loopback carrier     unmanaged
  2 eth0            ether    carrier     unmanaged
  3 docker0         bridge   routable    unmanaged
  4 br-b624c9fe6842 bridge   no-carrier  unmanaged
  5 br-efda3d097b3d bridge   routable    unmanaged
  6 vetha149762     ether    enslaved    unmanaged
  7 vethe7b3a71     ether    enslaved    unmanaged

7 links listed.

What I've tried:

I tried to restart the service:
Code:
root@docker:~# systemctl stop systemd-networkd.service
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket

Because of it, I tried to stop the `system-networkd.socket` service as well:
Code:
root@docker:~# systemctl stop systemd-networkd.socket

Then restarted everything again:
Code:
root@docker:~# systemctl start systemd-networkd.service

root@docker:~# systemctl status systemd-networkd.service
* systemd-networkd.service - Network Configuration
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; disabled; preset: disabled)
     Active: active (running) since Fri 2025-04-04 16:09:57 BST; 1min 27s ago
TriggeredBy: * systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
             man:org.freedesktop.network1(5)
   Main PID: 535957 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 18827)
     Memory: 1.5M
        CPU: 19ms
     CGroup: /system.slice/systemd-networkd.service
             `-535957 /lib/systemd/systemd-networkd

Apr 04 16:09:57 docker systemd[1]: Starting systemd-networkd.service - Network Configuration...
Apr 04 16:09:57 docker systemd-networkd[535957]: br-b624c9fe6842: Link UP
Apr 04 16:09:57 docker systemd-networkd[535957]: docker0: Link UP
Apr 04 16:09:57 docker systemd-networkd[535957]: eth0: Link UP
Apr 04 16:09:57 docker systemd-networkd[535957]: eth0: Gained carrier
Apr 04 16:09:57 docker systemd-networkd[535957]: lo: Link UP
Apr 04 16:09:57 docker systemd-networkd[535957]: lo: Gained carrier
Apr 04 16:09:57 docker systemd-networkd[535957]: Enumeration completed
Apr 04 16:09:57 docker systemd[1]: Started systemd-networkd.service - Network Configuration.

root@docker:~# systemctl start systemd-networkd.socket

I was expecting it to renew the lease. I'm not sure I'm wrong though:
Code:
root@docker:~# ip addr
...
2: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d0:c0:00:00:00:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0
...

The network interface seems to be correctly configured:
Code:
root@docker:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

# Added this as an attempt to fix it. Doesn't seen suitable, though. So removed...
allow-hotplug eth0

auto eth0
iface eth0 inet dhcp

# used to have eth1 and eth2 config here as well, but deleted after removing the interfaces in Proxmox.

Then I ran the DHCP client manually:
Code:
root@docker:~# dhclient

root@docker:~# ip addr
...
2: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether d0:c0:00:00:00:10 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.10.12/24 brd 10.0.10.255 scope global dynamic eth0
       valid_lft 86399sec preferred_lft 86399sec
...

However it seems to just be a palliative measure as it happened before.

Can someone shed a light?
 
Last edited: