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:

  1. Bring your network interfaces down:

    for i in $(ifconfig | egrep -o "^[a-z].+\d{1}:" | sed 's/://'); do sudo ifconfig "$i" down; done
    
  2. Flush the routing table: sudo route -n flush.

  3. Bring your interfaces back up again: (repeat step 1 with up instead of down).

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
}