OpenVZ : /etc/resolv.conf doesn't keep its content after the reboot

From vpsget wiki
Jump to: navigation, search

If you need some custom config in resolv.conf in your VPS (openvz) you can face that /etc/resolv.conf doesn't keep its content after the reboot. This is not a bug, it's OpenVZ "feature" changes applies to your container resolv.conf from node during container reboot/boot and your cofig become overwritten.

You can fix it by your self or request our support team to do it.

There several ways to fix current "feature":

1. You can simply change attributes on current files and node server will be not allowed to make changes. Run next command from container should stop any changes:

chattr +i /etc/resolv.conf 

2. You can crate a resolv.conf file with your config and copy it somewhere. After that create a new simple bash script with next content:

cp /root/resolv.conf /etc/resolv.conf

Add this script as startup in cron.

3. Request support to push necessary config for your vps. So changes will be made on the node server side.

""