NetworkManager Can Ignore VPN DHCP
Friday, August 6th, 2010Connecting to a VPN that has DHCP settings configured can be rather frustrating if it breaks your regular network settings. The biggest problem I’ve had with this in Ubuntu is with resolv.conf losing my DNS settings in favour of the VPN DNS settings.
For a long time I’ve tolerated the workaround of setting the immutable attribute on resolv.conf (ie. chattr +i /etc/resolv.conf). This will prevent anything from updating the file and thus you will not lose your DNS settings when the VPN connection takes place. This is fine for a desktop machine on a local network where resolv.conf is likely to stay static, but no good for a laptop or other mobile device.
This week I searched around for a better solution. Something new I found was vpnc connect and post-connect scripts. This looked like a possible solution, something similar to what I did when using the vpnc client for KDE. The KDE client had a post-connect script option, and from that I would restore my old resolv.conf. I tried creating the vpnc scripts to back up resov.conf and restore it afterwards, but it seems that those scripts don’t even get run by NetworkManager because nothing happened for me.
Then by luck I noticed something in my search results about a setting called ignore-auto-dns. Seems that the interface doesn’t support the setting, but you can specify it for the connection using gconf-editor. The specs for the setting are here… http://projects.gnome.org/NetworkManager/developers/settings-spec-08.html
So to apply this setting, open gconf-editor and find your VPN connection under system/networking/connections (all connections are just numbered under there). There should be an ipv4 key in there. Now just create the boolean value ignore-auto-dns and set it to true. Shortly after discovering this solution, I found another technique which lists this same setting but in a network configuration file… https://help.ubuntu.com/community/NetworkManager0.7. I’ve not tried the method listed there because I’m not actually convinced that it’s a better option than modifying this gconf setting.
If you have trouble figuring out what to enter into those fields, check out my old 
