Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using Ubuntu 12.04 LTS. I use a VPN for work. In network manager, for both my normal wired connection, and for the VPN connection also, I have it configured to "Automatic (VPN) addresses only" and I specify the nameservers I want to use. But when I view /etc/resolv.conf after connecting to the VPN, it shows different nameservers. Even after disconnecting from the VPN, it's using those nameservers that I did not specify.

The problem is this causes a large delay in browsing the web because the VPN nameservers are either really slow or maybe it's timing out.

How can I get it to stick to using the nameservers I specify?

If I edit resolv.conf and set it to the nameservers I want, the delay goes away, so I know this is the problem. But every time I use connect to the VPN, it just overwrites it again.

share|improve this question
up vote 1 down vote accepted


Starting from Ubuntu 12.04, some changes has been introduced into DNS resolving. It was announced here (Do read the VPN part). Also see its man page. Changes state that

resolvconf is a set of script and hooks managing DNS resolution. The most notable difference for the user is that any change manually done to /etc/resolv.conf will be lost as it gets overwritten next time something triggers resolvconf. Instead, resolvconf uses DHCP client hooks, a Network Manager plugin and /etc/network/interfaces to generate a list of nameservers and domain to put in /etc/resolv.conf.

You can refer to this answer on Ask Ubuntu.

share|improve this answer
I'm reading through all that and trying various things but it still is automatically injecting 2 nameservers in resolv.conf whenever I connect to the VPN. I gave up and just made /etc/resolv.conf a regular file. – taotree Jul 6 '12 at 11:19
If you want to add more entries to /etc/resolv.conf, create a /etc/resolvconf/resolv.conf.d/tail and add them there, BUT If /etc/resolv.conf contains, then adding entries to /etc/resolvconf/resolv.conf.d/tail won't really do anything useful. You should instead set the list of DNS servers statically in Network Manager which will then be configured in dnsmasq (that's running on – atenz Jul 6 '12 at 11:27 does show up. As I explained in my question, I did specify static DNS servers in Network Manager. But it appears to be ignoring them. – taotree Jul 8 '12 at 6:47
I would really suggest asking this question in Ask Ubuntu .I believe you will get better answer there , since Ubuntu related. Please unaccept this answer , since it doesn't solves your problem. Thank you. – atenz Jul 8 '12 at 7:39
Your answer led me to a solution, so I'll leave it accepted. Your reference to the question on Ask Ubuntu has very useful information. – taotree Jul 9 '12 at 17:54

Set resolv.conf to be immutable with chattr.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .