LXC containers not getting dhcp ip when start on boot

declan.marks

Member
Mar 7, 2021
5
0
6
28
I am having an issue when I set LXC containers set to start on boot. After starting up the containers are failing to get an IP address. I have to reboot the container and then it gets an IP address.

This is very annoying because I have lots of containers.
 
hi,
I am having an issue when I set LXC containers set to start on boot. After starting up the containers are failing to get an IP address.
where do they get the dhcp address from?

can you also post the container configuration pct config CTID

but from first glance it sounds like the dhcp server isn't up when the containers are starting on boot
 
where do they get the dhcp address from?
The address come from the DHCP server on my router (pfsense).

can you also post the container configuration pct config CTID
Code:
arch: amd64
cores: 1
features: nesting=1
hostname: pi-hole
memory: 400
nameserver: 8.8.8.8
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=D2:66:12:96:1E:46,ip=dhcp,tag=20,type=veth
onboot: 1
ostype: debian
rootfs: vmdata:subvol-108-disk-0,size=15G
startup: order=1
swap: 512

but from first glance it sounds like the dhcp server isn't up when the containers are starting on boot
This issue only occurs on containers. VMs can start on boot and get an IP address.
 
The address come from the DHCP server on my router (pfsense).
virtualized?
if it's virtualized then it will need to start before everything else to hand out the dhcp lease.

you can also try handing out specific IPs for the MAC address of your container (can be seen in config) from your pfsense and see if that helps.

do you see any dhcp-related entries in the syslog or journal of the container?
 
virtualized?
if it's virtualized then it will need to start before everything else to hand out the dhcp lease.
Not virtualized. External hardware.

you can also try handing out specific IPs for the MAC address of your container (can be seen in config) from your pfsense and see if that helps.
do you see any dhcp-related entries in the syslog or journal of the container?
Syslog after start on boot:
Code:
May 17 17:05:10 pi-hole ifup[78]: udhcpc: started, v1.30.1
May 17 17:05:10 pi-hole ifup[78]: udhcpc: sending discover
May 17 17:05:13 pi-hole ifup[78]: udhcpc: sending discover
May 17 17:05:17 pi-hole ifup[78]: udhcpc: sending discover
May 17 17:05:20 pi-hole ifup[78]: /etc/udhcpc/default.script: Lease failed:
May 17 17:05:20 pi-hole ifup[78]: udhcpc: no lease, failing

Syslog after container reboot
Code:
May 17 17:07:19 pi-hole ifup[79]: udhcpc: started, v1.30.1
May 17 17:07:19 pi-hole ifup[79]: udhcpc: sending discover
May 17 17:07:19 pi-hole ifup[79]: udhcpc: sending select for 192.168.20.10
May 17 17:07:19 pi-hole ifup[79]: udhcpc: lease of 192.168.20.10 obtained, lease time 7200
May 17 17:07:19 pi-hole ifup[79]: /etc/udhcpc/default.script: Resetting default routes
May 17 17:07:19 pi-hole ifup[79]: /etc/udhcpc/default.script: Adding DNS 192.168.20.1
 
I've just did a test. I am using Debian Turnekey core. It succusfully gets an IP address, but as soon as I use docker, this is when it fails to get IP on boot.
 
. It succusfully gets an IP address, but as soon as I use docker, this is when it fails to get IP on boot.
are you using docker on host? or inside the container?

does it work without docker in general?
 
here a standard debian container with docker can get the dhcp lease with onboot set. see my config:
Code:
# pct config 105
arch: amd64
cores: 1
features: nesting=1
hostname: pihole-docker
memory: 2048
net0: name=eth0,bridge=vmbr0,firewall=1,hwaddr=72:9F:58:19:8B:DB,ip=dhcp,type=veth
onboot: 1
ostype: debian
parent: clean
rootfs: local-lvm:vm-105-disk-0,size=8G
swap: 0
unprivileged: 1

however i didn't do the pihole install.

Code:
May 17 17:05:10 pi-hole ifup[78]: udhcpc: started, v1.30.1
May 17 17:05:10 pi-hole ifup[78]: udhcpc: sending discover
by default udhcpc is not installed in our debian template -- did you install that yourself (or as a part of pihole) ? that might be the reason it's having issues.

can you grep -i dhcp /var/log/syslog inside the container?

i also remember the pihole installation script (if you went that route) changes some network settings, which can mess with the PVE-generated network settings
 

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!