OVZ: prevent change hostname from container

From vpsget wiki
Revision as of 23:28, 26 June 2014 by Ndi (talk | contribs)
Jump to: navigation, search

OpenVZ could change the container hostname on reboot. To change container hostname permanently in easy way you can create the support request.

or you can simply change the hostname like described here:


There are exists several ways. For example you can make a cron to overwrite /etc/hosts or use some bootscripts.

BUT the easiest way is simply set attributes on the /etc/hosts to prevent it being modified on boot:


chattr +i /etc/hosts


If you also would like to set your own resolvers you can make the same with resolv.conf file:

 chattr +i /etc/resolv.conf  


Use

chattr -i 

to make it changeable on boot by ovz again.