I am using Virtual Box and if i lose internet connection or anything happens with my network adapter on host machine i will lose the internet connection on my Virtual Machine.
Even if i connect again, the host is fine but my Virtual Machine can't connect, i need to restart it in order to get internet.
Is there a way to restart networking on the Virtual Machine somehow without rebooting the whole Virtual Machine?
update:
i have tried this command:
sudo /etc/init.d/networking restart
but it just hangs and nothing happens.
This problem is very familiar as it seems and I have experimented a little and it turns out that you can change the network adapter while the VM is running here:
and then change only the
Attached to:
option to NAT or Bridged Adapter (mine was on Bridged adapter so i changed it to NAT).and click OK. And then change it again to which it was before and again click on OK to accept it.
Now go back to your VM terminal and run this command
Update:
for Ubuntu 18|20 run
to restart Networking
And the internet connection will work without reseting the VM.
Something that works for me is to turn off the network adapter and then turn it back on (go to the drop down box next to the battery icon in the far top right corner of the VM display and then do "Wired Connected" | "Turn Off" and then Turn On). That seems to jolt it out of its slumber. It is nevertheless very annoying as it seems like its up for about 10 or 15 minutes before it goes down again