AppleScript: McVPN
This bandaid is mighty handy for pesky OSX disconnects. I don't really know what causes it and unfortunately, I don't have time to fully figure it out. I do know that changing my gateway back to my local gateway helped tremendously. Also, changing my default nameserver to a local nameserver helped too. Now, I get disconnected but its after hours or days instead of minutes.
My system.log referred to lookupd issues and my ping had some sort of buffer problem. That's for you Googlers looking for a solution. Well, here's one...sorta. Throw this in a cron job run by root.
# Author: Chrissy LeMaire
Copyright 2003 NetNerds Consulting Group
Script is provided AS IS with no warranties or guarantees and assumes no liabilities.
Website: https://www.netnerds.net
try do shell script "date > /applescript/lastRan" do shell script "curl --connect-timeout 7 https://webserverOnVPN" on error do shell script "route flush" tell application "Internet Connect" set configName to "VPN" Disconnect end tell do shell script "route add default [localGateway]" tell application "Internet Connect" set configName to "VPN" Connect end tell delay 60 do shell script "route flush" -- just changing doesn't work nearly as well do shell script "route add default [localGateway]" -- so we flush and readd do shell script "route add -net [remoteSubnet] -netmask 255.255.255.0 [localGatway] -ifp ppp0" do shell script "echo "nameserver [localNameserver]" > /etc/resolv.conf" do shell script "date >> /applescript/dateLastBroken"
end try
This script requires that you have a webserver on the VPN..that's how it checks for a connection. Internet Connect will sometimes report that it's connected when it's not working so this is a better way to tell. It then issues a few commands to change the gateway back to the local one and then rewrites the resolv.conf so that DNS lookups are performed on a local dns server instead of over the VPN.
If I ever have the time figure out how to fix this intead of applying a band-aid, I'll be sure to update this page.