Hostname inconsistent GUI / container

cmonty14

Well-Known Member
Mar 4, 2014
343
5
58
Hi,
I have configured this hostname in GUI (see screenshot):
ct102-haproxy.whl.meilocal.net

However, the CLI output for displaying Fully qualified domain name returns:
ct102-haproxy:~# hostname -f
ct102-haproxy.whl.meilocal.net.local


How can this inconsistency be fixed?
 

Attachments

  • 2018-06-24_113350.jpg
    2018-06-24_113350.jpg
    26 KB · Views: 48
You're using the domain name provided by your PVE host. Check /etc/hosts.
 
Hi,
I have configured this hostname in GUI (see screenshot):
ct102-haproxy.whl.meilocal.net
That it FQDN (fully qualified domain name), not hostname.
You should define hostaname as "ct102-haproxy" with dns-domain "whl.meilocal.net"...
 
in DNS setting for the CT, you likely enabled 'Use host settings'. The host is probably using a .local domain.
 
This is /etc/hosts of Proxmox VE host:
root@pc4-svp:/etc/pve/local# cat /etc/hosts
127.0.0.1 pve.biszumbitterenen.de localhost.localdomain localhost
#127.0.1.1 pc4-pve.whl.meilocal.net pc4-svp
192.168.1.14 pc4-svp.whl.meilocal.net pc4-svp


# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters



What is wrong here?

And yes, in VM/CT configuration the setting in DNS is: Use host settings.
Where can I modify this for an existing VM/CT?
In the LXC config file?

FYI
This is the content of a LXC config file:
root@pc4-svp:/etc/pve/local# cat /etc/pve/lxc/102.conf
arch: amd64
cores: 1
hostname: ct102-haproxy.whl.meilocal.net
memory: 50
net0: name=eth0,bridge=vmbr0,gw=10.0.0.254,hwaddr=D6:B6:21:29:10:E6,ip=10.0.0.2/24,tag=1000,type=veth
onboot: 1
ostype: alpine
rootfs: images:102/vm-102-disk-1.raw,size=267596595
startup: order=1
swap: 8
 
Check the searchdomain on the node, might be that the .local is there.
 
/etc/resolv.conf on Proxmox VE
root@pc4-svp:/etc/pve/local# cat /etc/resolv.conf
search whl.meilocal.net
nameserver 5.45.97.127
nameserver 82.141.39.32
nameserver 46.28.207.199


/etc/resolv.conf on CT
ct102-haproxy:~# cat /etc/resolv.conf
# --- BEGIN PVE ---
search whl.meilocal.net
nameserver 5.45.97.127
nameserver 82.141.39.32
nameserver 46.28.207.199
# --- END PVE ---
 
If you use a other container, do you experience the same behavior?
 
Hm... interesting enough there are other containers where hostname -f returns correct FQHN.
 
I collected this information:
ct102-haproxy:~# cat /etc/alpine-release
3.7.0
ct102-haproxy:~# hostname -f
ct102-haproxy.whl.meilocal.net.local

ct108-cal:~# cat /etc/alpine-release
3.6.2
ct108-cal:~# hostname -f
ct108-cal.whl.meilocal.net


This could indicate that the issue is related to Alpine release.

The LXC config is identical, though:
root@pc4-svp:/# cat /etc/pve/local/lxc/102.conf
arch: amd64
cores: 1
hostname: ct102-haproxy.whl.meilocal.net
memory: 50
net0: name=eth0,bridge=vmbr0,gw=10.0.0.254,hwaddr=D6:B6:21:29:10:E6,ip=10.0.0.2/24,tag=1000,type=veth
onboot: 1
ostype: alpine
rootfs: images:102/vm-102-disk-1.raw,size=267596595
startup: order=1
swap: 8

root@pc4-svp:/# cat /etc/pve/local/lxc/108.conf
arch: amd64
cores: 1
hostname: ct108-cal.whl.meilocal.net
memory: 32
net0: name=eth0,bridge=vmbr0,gw=10.0.0.254,hwaddr=1E:68:FE:40:78:57,ip=10.0.0.8/24,tag=1000,type=veth
onboot: 0
ostype: alpine
rootfs: images:108/vm-108-disk-1.raw,size=307M
startup: order=5
swap: 8
unprivileged: 1
 
ct102-haproxy.whl.meilocal.net.local
Is that also what you see in the /etc/hosts and /etc/hostname?

Maybe alpine expects a dot on the end of the domain name?
 
ct108-cal:~# cat /etc/hosts

# --- BEGIN PVE ---
127.0.0.1 localhost.localnet localhost
::1 localhost.localnet localhost
10.0.0.8 ct108-cal.whl.meilocal.net ct108-cal
# --- END PVE ---
ct108-cal:~# cat /etc/hostname
ct108-cal
ct108-cal:~#
ct102-haproxy:~# cat /etc/hosts

# --- BEGIN PVE ---
10.0.0.2 ct102-haproxy.whl.meilocal.net ct102-haproxy
# --- END PVE ---
# begin generated by /etc/init.d/hosts
127.0.0.1 ct102-haproxy.whl.meilocal.net.local ct102-haproxy.whl.meilocal.net localhost
::1 ct102-haproxy.whl.meilocal.net.local ct102-haproxy.whl.meilocal.net localhost
# end generated


ct102-haproxy:~# cat /etc/hostname
ct102-haproxy


This output for ct102 shows an indication to the root cause: begin generated by /etc/init.d/hosts.

And this is the content of this file:
ct102-haproxy:~# cat /etc/init.d/hosts
#!/sbin/openrc-run

start() {
local start_tag='# begin generated'
local end_tag='# end generated'

local content=$(
cat <<-EOF
$start_tag by /etc/init.d/hosts
127.0.0.1 $(hostname).local $(hostname) localhost
::1 $(hostname).local $(hostname) localhost
$end_tag
EOF
)

if grep -q "^${start_tag}" /etc/hosts; then
# escape \n, busybox sed doesn't like them
content=${content//$'\n'/\\$'\n'}

sed -ni "/^${start_tag}/ {
a\\${content}
# read and discard next line and repeat until $end_tag or EOF
:a; n; /^${end_tag}/!ba; n
}; p" /etc/hosts
else
printf "$content" >> /etc/hosts
fi
}


Obviously this file was not executed on ct108.
 
Last edited:
Which alpine versions are these two containers running?

To avoid the modifications try the following.
Modification of a file can be prevented by adding a .pve-ignore. file for it. For instance, if the file /etc/.pve-ignore.hosts exists then the /etc/hosts file will not be touched. This can be a simple empty file created via:

# touch /etc/.pve-ignore.hosts

Most modifications are OS dependent, so they differ between different distributions and versions. You can completely disable modifications by manually setting the ostype to unmanaged.
 
Hi,
both servers are running with same Alpine release 3.7.0.
However, ct102 was originally created with template "alpine-3.6-default_20171211_amd64" and then upgraded to Alpine 3.7, but ct108 was created with latest template "alpine-3.7-default_20171211_amd64".
This means the erroneous CT originates from a different template.
 
This has apparently changed in that version, the template is pulled directly from LXC image repository. You could remove the init script or use the above mentioned ignore file.
 

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!