[Users] /etc/hosts

Kirill Korotaev dev at sw.ru
Tue Dec 12 09:59:05 EST 2006


> Kirill Korotaev wrote:
> 
>>Farkas Levente wrote:
>>
>>>hi,
>>>why put openvz into each VE's /etc/hosts the hostname itself too? ie:
>>>127.0.0.1  host.example.com host localhost localhost.localdomain
>>>and why do this on all reboot, why not accept
>>>127.0.0.1  localhost localhost.localdomain
>>>it has some reasons?
>>>thanks.
>>>yours.
>>>
>>
>>If HOSTNAME set in VE config it is updated on every VE start.
>>hostname is bound to 127.0.0.1 for simplicity of  updates on  ip change  i.e  
>>it doesn't depend on ip in such a scheme.
> 
> 
> ok, but in this case all tool like netstat, iptables etc.. assumes
> 127.0.0.1 as hostname and it's really annoying netstat -lt:
> ------------------------------
> # netstat -lt
> tcp        0      0 host.example.com:smtp     *:*     LISTEN
> tcp        0      0 host.example.com:smtp     *:*     LISTEN
> # netstat -ltn
> tcp        0      0 127.0.0.1:smtp     *:*     LISTEN
> tcp        0      0 1.2.3.4:smtp       *:*     LISTEN
> ------------------------------
Ah, I see...
There are 2 easy choices here:
- change your VE /etc/hosts and add a "real-IP hostname" line to it.
  vzctl will notice it and will stop changing it.
  actually one manage hostnames itself from VE this way.
- fix vzctl to add such lines, however, it is harder,
  since will require /etc/hosts modification on each ipadd/ipdel/hostname-change
  etc. and it is not clear how to leave the ability to manage /etc/hosts from inside VE.

Thanks,
Kirill



More information about the Users mailing list