Juniper's Network Connect VPN client seems to leave an OS X network interface in an unusable state if it does not disconnect gracefully.
Edit: "disconnect gracefully" refers to any time the VPN drops for reasons other than clicking the "Sign Out" button on the software client. This happens when the wifi drops out long enough to cause the VPN to drop, or perhaps I closed the laptop screen without remembering to disconnect, etc.
From the terminal, a simple ping gets you the following result:
ping: sendto: Cannot allocate memory
Rebooting solves the problem, but that is inconvenient.
Using ifconfig to reset the interface does not work:
ifconfig en0 down
ifconfig en0 up
Neither does flushing the route table:
route -n flush
I also tried resetting the DNS cache (completely irrelevant, but I figured I would give it a try anyway). That obviously did not work.
launchctl unload /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
launchctl load /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
What finally worked reliably was to shut off IPv4, and then turn it back on using the following steps:
- Open System Preferences
- Click on the Network Icon
- Click on the broken interface.
- Click the Advanced button.
- Select TCP/IP
- Select "Off" under Configure IPv4.
- Select "OK"
- Select "Apply".
- Do steps 4 - 8 again, but replace 6 with your desired IP configuration method.
So to my question... Is there a way to achieve the same as steps 1-9 above from the command line? Ideally I would like to be able to call a bash script to do the reset.
Note: This was tested on OS X Mountain Lion and OS X Yosemite. I skipped over OS X Mavericks, hence the reason I omitted that specific tag. I have every reason this applies to Mavericks as well, but I cannot prove it.