Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vagrant: a better to way to "reset" my guest vagrant vm's network?

Tags:

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?

like image 923
Calvin Cheng Avatar asked Apr 30 '12 03:04

Calvin Cheng


People also ask

How to reset the Vagrant virtual environment to its default state?

After you explored the virtual environment and if you don't want it anymore, simply wipe it and re-create a clean virtual environment. Before you reset the Vagrant machine to it's default state, backup your work and then shutdown the VM: You can also use the following command from the hostname system to shutdown the vagrant virtual machine:

How do I deploy a Vagrant virtual machine to another system?

You can quickly spin up a virtual machine using a pre-configured Vagrant box and copy the same Vagrant box to other systems to deploy a exact replica of the current development environment. Once you're done exploring your development environment, you can simply reset the Vagrant machine back to it's original default state.

What happens when you delete a Vagrant box?

The vagrant machine has been reset to it's default original state. All customizations and installed software in the Virtual machine will be gone. You should now have a fresh virtual machine. As you see in the above example, I didn't delete the Oracle Linux 8 Vagrant box and re-download it.

What is vagrant and why should I use it?

As you may already, Vagrant is an open source application to build and maintain virtual software development environments. You can quickly spin up a virtual machine using a pre-configured Vagrant box and copy the same Vagrant box to other systems to deploy a exact replica of the current development environment.


2 Answers

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:

sudo /etc/init.d/networking restart 
like image 152
Mitchell Avatar answered Jan 05 '23 09:01

Mitchell


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!

like image 26
Ruy Garcia Avatar answered Jan 05 '23 08:01

Ruy Garcia