Linux Container wrong hostname in /etc/hosts

talos

Renowned Member
Aug 9, 2015
69
9
73
Hi,

i deployed a few CentOS7 LXC Containers today. After taking a look in /etc/hosts i found this..

127.0.0.1 localhost LXC_NAME
# --- BEGIN PVE ---
::1 localhost.localnet localhost
10.48.4.116 xxx.yyy.com xxx
# --- END PVE ---

The Line 127.0.0.1 contain a placeholder for LXC_NAME instead the full hostname, i think this is wrong.

Output from pveversion:
proxmox-ve: 4.4-82 (running kernel: 4.4.40-1-pve)
pve-manager: 4.4-12 (running version: 4.4-12/e71b7a74)
pve-kernel-4.4.40-1-pve: 4.4.40-82
lvm2: 2.02.116-pve3
corosync-pve: 2.4.2-1
libqb0: 1.0-1
pve-cluster: 4.0-48
qemu-server: 4.0-109
pve-firmware: 1.1-10
libpve-common-perl: 4.0-92
libpve-access-control: 4.0-23
libpve-storage-perl: 4.0-76
pve-libspice-server1: 0.12.8-2
vncterm: 1.3-1
pve-docs: 4.4-3
pve-qemu-kvm: 2.7.1-4
pve-container: 1.0-94
pve-firewall: 2.0-33
pve-ha-manager: 1.0-40
ksm-control-daemon: 1.2-1
glusterfs-client: 3.5.2-2+deb8u3
lxc-pve: 2.0.7-3
lxcfs: 2.0.6-pve1
criu: 1.6.0-1
novnc-pve: 0.5-8
smartmontools: 6.5+svn4324-1~pve80
zfsutils: 0.6.5.9-pve15~bpo80
openvswitch-switch: 2.6.0-2
 
I've noticed this as well, this is from a CentOS 7 machine:

Code:
127.0.0.1               localhost LXC_NAME
# --- BEGIN PVE ---
::1            localhost.localnet localhost
# --- END PVE ---
144.xxx.xxx.168         host.name.com hostname

Nobody know what the cause for this is?
 
probably an issue with the template - please file a bug at bugzilla.proxmox.com with the exact template name/version.
 
In my case I have a bunch of lxc containers converted from openvz where we set the hosts entries manually. They all contain the proper host name, yet proxmox puts the following lines in the /etc/hosts file:

Code:
# --- BEGIN PVE ---
127.0.1.1 xxxhost
# --- END PVE ---

But all hosts files contain the proper host entry already, like:

Code:
10.1.2.3 xxxhost.company.local xxxhost

I think this is a bug. When a valid entry exists in the hosts file for the current container host name, this entry is not needed. This currently makes a mess of name resolution and warning left and right for services on startup or in the log files. Openvz used to work properly in this regard.

Using /etc/.pve-ignore.hosts is not a proper solution since it blocks future attempts at setting the host name from the web interface. It's quirky and a source of obscure mistakes.
 
see

https://pve.proxmox.com/wiki/Linux_Container#_guest_operating_system_configuration

We thing using .pve-ignore is the correct way to avoid overwriting.

For now I think we can live with it (I also mentioned this solution exists), however, could you please explain what the purpose is for adding an entry for 127.0.1.1? When other entries are already added in the file for the same host name. The flag file approach is somewhat faulty because it's not apparent on the web interface that an override is in effect.
 

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!