How to create custom /etc/resolv.conf?

You may notice that everytime you reboot your VPS, the changes you made on your /etc/resolv.conf file is being replaced with the default settings. This is common to OpenVZ technology because it uses scripts that when a container is rebooted, it replaces all the config files to the default for security reasons.

The workaround so that your /etc/resolv.conf won't get replaced each reboot occurence are the following.

Before anything else, make a backup of all your changes to resolv.conf and place it somewhere like "/backup" directory.

Workaround 1: Open your /etc/rc.local and add one of the two commands below.

cp /backup/resolv.conf /etc/resolv.conf


OR

echo 'nameserver 4.4.8.8' > /etc/resolv.conf


(4.4.8.8 is only an example)


Workaround 2: Create a startup script and use "@reboot" crontab command (it will execute your script only after reboot)

Key in:

#export EDITOR=nano
#
crontab -e


Then add:

@reboot cp /backup/resolv.conf /etc/resolv.conf


Both workarounds will replace your resolv.conf each reboot occurence so that your changes are preserved even OpenVZ replaces them. Hope this helps!

  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Common SSH Commands - Linux Shell Commands

ear. Updated: Jan 19, 2007: Added some new ssh commands for the linux shell.We've put together...

Can you install Ragnarok Private Server to my VPS for free?

Ragnarok Online Private Server installation, while possible to be run on our VPS, is not included...

How to create an FTP account with SSH

This tutorial will tell actually not only teach you how to create an FTP Account, but will also...

How to change the root Password using SSH

This article will show you how to change the root password for your Root Server using SSH For...

VPS Reseller Demo

You may login and test our VPS Reseller panel below.SolusVM Reseller Control Panel URL:...