Difference between revisions of "OVZ: prevent change hostname from container"

From vpsget wiki
Jump to: navigation, search
(Created page with "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 ho...")
 
 
(One intermediate revision by the same user not shown)
Line 4: Line 4:
 
or you can simply change the hostname like described here:
 
or you can simply change the hostname like described here:
  
and after simply set attributes on the /etc/resolve.conf to prevent it being modified on  boot:
 
  
 +
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/resolv.conf
 
  
Or/and:
 
 
  chattr +i /etc/hosts
 
  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  
 
Use  
 
  chattr -i  
 
  chattr -i  
  
should you ever need to change it again
+
to make it changeable on boot by ovz again.
 +
 
 +
[[Category:Admin area]]

Latest revision as of 23:29, 26 June 2014

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.