Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:

nameserver 127.0.0.1
search mylocalnetwork

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

nameserver X.X.X.X
nameserver X.X.X.Z
nameserver 127.0.0.1
search internal.mycompany.com mylocalnetwork

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

7$ cat bin/refreshResolvconf.sh 
#!/bin/bash
#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`" == "" ]
then 
/sbin/resolvconf -d tun0;
echo "Refreshed resolv.conf"
fi

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.