I am relatively new to vagrant but certainly liking it so far.
One of the little problem I often face is that when my host machine's network goes down momentarily, it affects my connection to my vagrant guest vm.
When my host machine's network comes back up again, I have to - on my host machine - run vagrant halt
and then vagrant up
in order to "reset" my guest vagrant vm's network so that it can connect to the internet once again.
Is there a more "elegant" way of getting my vm's internet connection via my host machine's network to detect that the internet network connection is back up?
Here's what i did:
HOST=VM IP Address PRIVATE_KEY_PATH= Private key path
ssh vagrant@$HOST -i $PRIVATE_KEY_PATH
to login to the VMThen,
sudo /etc/init.d/networking restart
Updated version (year 2018) of the command listed in other answers*:
For Ubuntu 16.04.* LTS (Xenial Xerus):
For CentOS 7.5 (
network
vsnetworking
is quite unfortunate difference, but here we are):*In modern distributions scripts listed in the answers are just wrappers around
systemd
'ssystemctl
.Regarding what Mitchell answers, for my Vagrant version 1.5.2 the command is little different:
sudo /etc/init.d/network restart
Instead of using "networking". I know is not a big deal, but just wanted to say it.
Great work with Vagrant Mitchell!
Yes, the easiest solution is to restart the networking subsystem within the VM itself. SSH connections shouldn't be interrupted. On Ubuntu, do the following: