Proxmox CT does not configure hostname properly for DHCP on Alpine & Debian templates

senkwich

New Member
Jul 13, 2020
2
0
1
35
I recently set up Proxmox 6.2 onto a couple of old servers and was running through configuring some LXC instances. I've tried the following with only ArchLinux working as expected:

  • alpine-3.10-default_20190626_amd64.tar.xz (does not work)
  • alpine-3.11-default_20200425_amd64.tar.xz (does not work)
  • debian-10.0-standard_10.0-1_amd64.tar.gz (does not work)
  • debian-9.0-standard_9.7-1_amd64.tar.gz (does not work)
  • debian-10-turnkey-gitea_16.0-1_amd64.tar.gz (does not work)
  • archlinux-base_20200508-1_amd64.tar.gz (works)

I've got a Ubiquiti Edge Lite 3 configured with dnsmasq to map hostnames to IP addresses via DHCP. E.g. if I run a machine with the hostname "git" that is assigned IP address 192.168.1.100, dnsmasq will route git.my.domain to 192.168.1.100.

What I've discovered is that with the alpine and debian images above, they use udhcpc as the client, which seems to not pick up the hostname to send as a parameter/option to the DHCP server. If I manually run udhcpc renew -x hostname:git, the hostname is picked up and correctly set by dnsmasq, but this would require me to run this whenever the container starts up.

I tried editing some udhcpc configs, but couldn't get it to change. Finally, I read several places online where editing /etc/network/interfaces to include hostname as a configuration would set it. The challenge was that the interfaces file was being overwritten by proxmox; so, I had to touch /etc/network/.pve-ignore.interfaces in order to add the setting to the generated file:


Code:
auto lo
iface lo inet loopback
iface lo inet6 loopback

auto eth0
iface eth0 inet dhcp
hostname $(hostname) <-- added this line

iface eth0 inet6 manual

Adding the ignore and rebooting the container fixed my problem and dnsmasq picked up the hostname for use locally. Is this expected for LXC containers? I'd prefer to not need to edit the interfaces file manually nor mark it for being ignored by pve. Is there a better way to do this?
 
could you file an issue over at https://bugzilla.proxmox.com ? looks like something that we could add to our network setup code for select distros..
 
Can confirm I saw the same in the turnkey wordpress image.

udhcpc renew -x hostname:`cat /etc/hostname` solved this, until the next start. Looking for a place like /etc/rc.local.
 
Hmm, 4 years later and the issue is still around. Is senkwich' solution in post #1 really still best practice?
No. I think there are far simpler workarounds.

udhcpc renew -x hostname:`cat /etc/hostname` solved this. Add it to rc.local is complicated. But I find add it to crontab is far easier. I added the following in crontab:

# sleep 30 to avoid race condition
@reboot sleep 30; /usr/sbin/udhcpc renew -x hostname:`cat /etc/hostname`

Without the 30 seconds sleep, the hostname is not consistently set in the DHCP interaction.

I have opened a case against the turnkey linux: https://github.com/turnkeylinux/tracker/issues/1992
 
Last edited:
Can confirm I saw the same in the turnkey wordpress image.

udhcpc renew -x hostname:`cat /etc/hostname` solved this, until the next start. Looking for a place like /etc/rc.local.
Yes, the problem appears in wordpress image because it's based on Turnkey Core LXC template. Anything built with Turnkey Core LXC templates suffer from this bug.

Good suggestion about the command to renew with a hostname. But I used crontab instead, it's a much simpler workaround.
 
Last edited:
I can confirm 3 years later, this bug still exists in the later Turnkey Core LXC, version 18.x.
Debian 12.x standard LXC templates do not suffer from this problem.

Too bad, this problem persists for so long and the bug is in Turnkey's codes.
Geez, that's annoying! 2025 and I ran into that with Turᴎkey NAS container not sending name properly...