OVZ: prevent change hostname from container

From vpsget wiki
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  


chattr -i 

to make it changeable on boot by ovz again.