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 instead of up).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
}
You can tear down and start up the network interface using:
sudo ifconfig en0 down
sudo ifconfig en0 up
launchctl(8) is your friend. Just keep in mind that some of the services (sshd for example) are disabled in the configuration file so you will need to use the switch when loading them. Here is a sshd example:-w
$ sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
You can stop the service using the subcommand.unload
$ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
To list the services, as you might have already guessed use the 'list' subcommand ;)

The standard Reboot UI has the checkbox that could be toggled programmatically:
$ defaults write com.apple.loginwindow TALLogoutSavesState -bool false
You can use interactively from the terminal. Run scutil and run these commands, swapping your DNS servers in where appropriate:sudo scutil
> open > d.init > d.add ServerAddresses * 8.8.8.8 9.9.9.9 > set State:/Network/Service/PRIMARY_SERVICE_ID/DNS > quit
Instead of using and 8.8.8.8 use your DNS servers.9.9.9.9
The only problem is this is not persistent across reboots. If you want permanent changes, you'll want ncutil. The reason editing isn't sufficient in newer versions of OS X is because configd now uses a database to store information of current settings, which other applications read. Certain applications will still read /etc/resolv.conf (host for example), although that is not the case for all applications./etc/resolv.conf
Once you've logged in via ssh then you need to use with the shutdown flag (for restart):-r
$ ssh username@ip-address
$ sudo /sbin/shutdown -r now
Or, to do it all in one command:
$ ssh username@ip-address sudo /sbin/shutdown -r now
You could easily achieve this using (which is, actually, a wrapper for mount_smbfs) : mount -t smbfs
mount_smbfs //user@SERVER/folder ./mntpoint
Optionally, add the workgroup :
mount_smbfs -W workgroup //user@SERVER/folder ./mntpoint
You could, of course, change the (for something like ./mntpoint)./Volumes/smb
After doing this, simply go to to browse your data../mntpoint
To unmount, using the following command :
umount ./mntpoint
Specifically for Docker for Mac, because it's a "GUI" app, there's a workaround:
osascript -e 'quit app "Docker"'
Since you'd want to restart, here's the way to open it from the command line:
open -a Docker
There's probably a more symmetrical command to open using , but the osascript command seems more common than the open one.osascript