Restart network config from terminal
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:
for i in $(ifconfig | egrep -o "^[a-z].+\d{1}:" | sed 's/://'); do sudo ifconfig "$i" down; done
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:
resetroute () {
echo "Flushing routes...";
for i in $(ifconfig | egrep -o "^[a-z].+\d{1}:" | sed 's/://');
do
sudo ifconfig "$i" down;
done;
sudo route -n flush;
for i in $(ifconfig | egrep -o "^[a-z].+\d{1}:" | sed 's/://');
do
sudo ifconfig "$i" up;
done
}