hosts file

pva00

New Member
Apr 20, 2009
21
1
1
Is is possible to change the auto generated host file for openvz from:

# Auto-generated hostname. Please do not remove this comment.
127.0.0.1 ls2.local.lan localhost ls2 ls0 localhost.localdomain

To

# Auto-generated hostname. Please do not remove this comment.
127.0.0.1 localhost localhost.localdomain
127.0.1.1 ls2 ls2.local.lan

ls2 is the hostname and ls2.local.lan is the fdqn
Note that ls0 is also added ???? an other openvz system (the first created)
 
  • Like
Reactions: paxmobile
Is is possible to change the auto generated host file for openvz from:

# Auto-generated hostname. Please do not remove this comment.
127.0.0.1 ls2.local.lan localhost ls2 ls0 localhost.localdomain

To

# Auto-generated hostname. Please do not remove this comment.
127.0.0.1 localhost localhost.localdomain
127.0.1.1 ls2 ls2.local.lan

ls2 is the hostname and ls2.local.lan is the fdqn
Note that ls0 is also added ???? an other openvz system (the first created)

Yes you can! Open the Machine, and on Network tab write on Hostname: ls2.local.lan and on Domain name: local.lan; on DNS fields write twice 127.0.1.1. Save the changes & Stop/Start the OpenVZ machine.

Remember, if you add 127.0.1.1 on IP machine you can not access this via ssh or other protocols! Try to explain why you need to make this settings!

PS: don't forget to add forwarders on DNS to be capable to connect external hosts!
 
Last edited:
Thank you for the proposed solution, but does solve the problem. The 127.x.x.x range can be used for the local loopback adapter. Try to ping it. So splitting the localhost and the fqdn over 2 local loopback IPs wil work. Some linux distributions do so.

I stick by the request to split localhost and the fqdn name in the hosts file over 2 local loopback IPs.

Some applications want only localhost attached to 127.0.0.1, for instance zimbra at installaion gives an error.

I noticed more problems with the auto generated hosts file. The (short)hostnames of other (deleted) openvz containers apear in the file. Deleted openvz containers which had the same VMID.
 
Thank you for the proposed solution, but does solve the problem. The 127.x.x.x range can be used for the local loopback adapter. Try to ping it. So splitting the localhost and the fqdn over 2 local loopback IPs wil work. Some linux distributions do so.

I stick by the request to split localhost and the fqdn name in the hosts file over 2 local loopback IPs.

above solution works for me. I get
Code:
127.0.0.1 localhost.localdomain localhost
127.0.1.1 ls2.local.lan ls2

which is what you want?

I noticed more problems with the auto generated hosts file. The (short)hostnames of other (deleted) openvz containers apear in the file. Deleted openvz containers which had the same VMID.

If you change the hostname, both the previous and new hostnames are listed (I can reproduce that bug). But do you relly get hostnames from deleted VMs?
 
hosts

What I have in my /etc/hosts file is:

127.0.0.1 localhost
127.0.1.1 <FQDN> <hostname>

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

So all are desired.
-------------
I did some tests and I don't get hostnames of deleted containers. I made a template of an openvz container and if I create a new openvz container from this template, I get also the hostname in the /etc/hosts file of the template during creation of the template. Or I have to delete the etc/hosts file before creating an openvz template or the /etc/hosts file must be rewritten during creation of a openvz container.
 
I made a template of an openvz container and if I create a new openvz container from this template, I get also the hostname in the /etc/hosts file of the template during creation of the template. Or I have to delete the etc/hosts file before creating an openvz template or the /etc/hosts file must be rewritten during creation of a openvz container.

A template should not contain a hostname (use localhost). (Use 'dab' to create templates).
 
hosts

I used dab but it gives some errors, I 'll look into it later on. I removed the etc/hosts file and every things looks fine. But after changing the hostname through the proxmox gui, I 'll get the old and new hostname in the etc/hosts 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!