LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   A solution to VPN resolve.conf being overwritted by dhclient in Ubuntu 10.4 (https://www.linuxquestions.org/questions/linux-newbie-8/a-solution-to-vpn-resolve-conf-being-overwritted-by-dhclient-in-ubuntu-10-4-a-934596/)

rgreenbank 03-15-2012 09:02 AM

A solution to VPN resolve.conf being overwritted by dhclient in Ubuntu 10.4
 
Hi,

If anyone has found a better way to do this, I'd love to hear.

Problem: After switching from DSL to cable internet, my resolve.conf is now periodically overwritted (I'm not sure why this didn't happen with DSL). This causes problems with my VPN connection, as I suddenly can't resolve servers/hosts at work.

Reading through dhclient documentation I found the "hooks" scripts, which can either be placed in a directory, or a single "dhcp-enter-hooks" file in /etc/dhcp3. This file is sourced by /sbin/dhclient-script prior to actually doing anything, and since it's sourced, an "exit" will stop the script.

My solution is pretty simple. The VPN creates an interface called "tun0" on my system, so my script checks for that interface and exits if found. I'll post the script below.

I tested it both with and without VPN connected, and it seems to work well.

Rob Greenbank
Adaptive Computing

--------------/etc/dhcp3/dhclient-enter-hooks---------------
#
# Exit the dcclient script if VPN is up. On this system, the VPN
# is "tun0", so exit if an error is NOT returned on "ifconfig tun0"
VPN_IF="tun0"

ifconfig -a | grep -q ${VPN_IF}

if [ $? = 0 ]; then
exit 0
fi


All times are GMT -5. The time now is 07:20 AM.