I've been having a problem where my macbook won't reconnect to the internet after I turn off my work VPN. A simple reboot fixes this, but I was wondering if there was a way I could restart the network configs, or clear cache (not sure exactly what the problem is) from the command line – without having to do a reboot?
I've tried the following, without success
$ ifconfig en0 down && ifconfig en0 up
Is there a way to reset the network config to whatever the default values are after a reboot?
Edit: This doesn't happen every time, I'm not exactly sure what chain of events triggers it.
Best Answer
Lack of network access after disconnecting from a VPN can be a symptom of a routing issue. If your VPN client doesn't disconnect cleanly, the gateway that directs your traffic to the virtual network can sometimes be left in place, effectively routing your traffic to a dead end.
I'd suggest bringing your interfaces down, flushing the routing table of gateway entries, and bringing them up again:
Bring your network interfaces down:
Flush the routing table:
sudo route -n flush
.Bring your interfaces back up again: (repeat step 1 with
up
instead ofdown
).If you want a reusable Bash function for this that you can drop into your .bashrc (or wherever), you could save the following: