LXC containers not receiving IPv4 addresses

red2503

New Member
Nov 30, 2023
3
0
1
Hello, I am new to Proxmox. I have some problems with obtaining IPv4 addresses from dhcp in my LXC containers.

When I reboot my LXC containers, they won't receive an IPv4 address anymore. I am not sure if this is related, but it seems this started occurring after I ran the following commands on the node:
Bash:
systemctl restart pvedaemon
systemctl restart pvestatd
systemctl restart pveproxy
systemctl restart corosync

Network interfaces on node:
Bash:
root@proxmox:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

iface enp3s0 inet manual

auto vmbr0
iface vmbr0 inet dhcp
        address 192.168.1.100/24
        gateway 192.168.1.1
        bridge-ports enp3s0
        bridge-stp off
        bridge-fd 0

iface wlp1s0 inet manual

Running pct config on node:
Bash:
root@proxmox:~# pct config 100
arch: amd64
cores: 4
description:  USB passthrough%0A VAAPI hardware transcoding%0A
features: mount=cifs,nesting=1
hostname: plex
memory: 4096
net0: name=eth0,bridge=vmbr0,hwaddr=BC:24:11:39:38:AC,ip=dhcp,type=veth
onboot: 1
ostype: ubuntu
rootfs: local-lvm:vm-100-disk-0,size=48G
swap: 4096
tags: proxmox-helper-scripts
lxc.cgroup2.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 188:* rwm
lxc.cgroup2.devices.allow: c 189:* rwm
lxc.mount.entry: /dev/serial/by-id  dev/serial/by-id  none bind,optional,create=dir
lxc.mount.entry: /dev/ttyUSB0       dev/ttyUSB0       none bind,optional,create=file
lxc.mount.entry: /dev/ttyUSB1       dev/ttyUSB1       none bind,optional,create=file
lxc.mount.entry: /dev/ttyACM0       dev/ttyACM0       none bind,optional,create=file
lxc.mount.entry: /dev/ttyACM1       dev/ttyACM1       none bind,optional,create=file
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file


Running ip a on one of the containers:
Bash:
root@plex:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether bc:24:11:39:38:ac brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::be24:11ff:fe39:38ac/64 scope link 
       valid_lft forever preferred_lft forever


When I run the commands below in a container, this container will receive an IPv4 address, but it will lose this IPv4 again after rebooting it. If possible, I want all containers to receive an IPv4 address automatically after rebooting, just as it worked previously.
Bash:
dhclient -r eth0
dhclient eth0
 
Is there anything in the startup log of the CT? How long does starting the container take?

What kind of DHCP server are you using? Do you have access to any logs of your DHCP server to see if the requests are reaching the server?
 
Is there anything in the startup log of the CT? How long does starting the container take?

What kind of DHCP server are you using? Do you have access to any logs of your DHCP server to see if the requests are reaching the server?
Do you mean /var/log/syslog in the container? Starting the container takes just 1 second.

The router from my ISP is my DHCP server. The log of my router shows this after starting a container:

#TimeFacilityLevelCategoryMessages
1Nov 30 13:36:25daemoninfodhcpddnsmasq-dhcp: read /etc/ethers - 0 addresses
2Nov 30 13:36:25daemoninfodhcpddnsmasq-dhcp: DHCP, IP range 192.168.1.2 -- 192.168.1.254, lease time 1d
3Nov 30 13:36:18daemoninfodhcpddnsmasq-dhcp: read /etc/ethers - 0 addresses
4Nov 30 13:36:18daemoninfodhcpddnsmasq-dhcp: DHCP, IP range 192.168.1.2 -- 192.168.1.254, lease time 1d
5Nov 30 13:36:16daemoninfodhcpddnsmasq-dhcp: read /etc/ethers - 0 addresses
6Nov 30 13:36:16daemoninfodhcpddnsmasq-dhcp: DHCP, IP range 192.168.1.2 -- 192.168.1.254, lease time 1d
 
Do you mean /var/log/syslog in the container?
I meant from the Container startup - You can find it in the Web UI when clicking on the Node and then Task History. There you should find a Start Task for your container.

The router from my ISP is my DHCP server. The log of my router shows this after starting a container:
This looks like dnsmasq on your router is constantly restarting or reloading its configuration, which seems a bit odd. Can you try to tcpdump on your host on vmbr0 and check whether any DHCP requests go out / come back in again? You can use the following command:

Code:
tcpdump -i vmbr0 port 67 or port 68 -e -n -vv


Also it seems like you have a static IP configured on vmbr0 - even though the mode is set to dhcp. It would make sense to set the static mapping for your host in your router and remove the static mapping from the network configuration.
 
I meant from the Container startup - You can find it in the Web UI when clicking on the Node and then Task History. There you should find a Start Task for your container.
Thank you. I checked it, it says "TASK OK".

This looks like dnsmasq on your router is constantly restarting or reloading its configuration, which seems a bit odd. Can you try to tcpdump on your host on vmbr0 and check whether any DHCP requests go out / come back in again? You can use the following command:

Code:
tcpdump -i vmbr0 port 67 or port 68 -e -n -vv
It shows this multiple times:
Bash:
root@proxmox:~# tcpdump -i vmbr0 port 67 or port 68 -e -n -vv
tcpdump: listening on vmbr0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
14:44:23.505381 bc:24:11:39:38:ac > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 329: (tos 0xc0, ttl 64, id 0, offset 0, flags [none], proto UDP (17), length 315)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from bc:24:11:39:38:ac, length 287, xid 0x93f9959c, secs 1, Flags [none] (0x0000)
          Client-Ethernet-Address bc:24:11:39:38:ac
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message (53), length 1: Discover
            Client-ID (61), length 19: hardware-type 255, 14:c2:c6:54:00:02:00:00:ab:11:df:ef:c9:15:7c:e3:cd:e1
            Parameter-Request (55), length 10:
              Subnet-Mask (1), Default-Gateway (3), Domain-Name-Server (6), Hostname (12)
              Domain-Name (15), Static-Route (33), NTP (42), Unknown (119)
              Unknown (120), Classless-Static-Route (121)
            MSZ (57), length 2: 576
            Hostname (12), length 4: "plex"

Also it seems like you have a static IP configured on vmbr0 - even though the mode is set to dhcp. It would make sense to set the static mapping for your host in your router and remove the static mapping from the network configuration
I assume you mean I have to remove the lines containing address and gateway in /etc/network/interfaces? I tried it, but it did not help.
 
finally found a way.
Indeed a vlan issue it seems.
So this fixed it for me:

https://wiki.debian.org/LXC/VlanNetworking

In my case , snippet from /etc/network/interfaces:
allow-hotplug eth1
auto eth1
iface eth1 inet dhcp

iface eth1.111 inet manual

auto br0.111
iface br0.111 inet manual
bridge_ports eth1.111
bridge_fd 0
bridge_maxwait 0

then dhcpcd eth1 and the route is added and all works.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!