Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 connect to VPN using vpnc. When VPN disconnects, either via time out or the session limit is reached, VPN is terminated, but resolve.conf continues to contain references to my VPN network.

resolv.conf before VPN is connected:

search mylocalnetwork

resolv.conf after VPN is connected and remains once VPN is lost:

nameserver X.X.X.X
nameserver X.X.X.Z
search mylocalnetwork

In 10.04, when VPN lost, I'd run this script to refresh resolve.conf:

7$ cat bin/ 
#if [ -e /etc/resolvconf/run/interface/tun0 -a "`pidof vpnc`" == "" ]; then /sbin/resolvconf -d tun0; fi
if [ -e /etc/resolvconf/run/interface/tun0 -a "`pidof vpnc`" == "" ]
/sbin/resolvconf -d tun0;
echo "Refreshed resolv.conf"

But, resolveconf changed in 12.04 changed, so this script is no longer applicable.

To resolve, I manually edit resolve.conf or turn off/on my connection via "gnome-control-center network".

Anyone else have the same problem? How can resolv.conf be updated post-VPN disconnect?

share|improve this question

The path /etc/resolvconf/run is no longer used.

The following snippet will delete the tun0 record if no vpnc process is running.

[ "$(pidof vpnc)" ] || resolvconf -d tun0

The correct solution to the problem would be to arrange for vpnc to be terminated in such a way that it cleans up before exiting, where cleaning up includes deleting any resolvconf records it created when it connected.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.