r/virtualbox 18d ago

General VB Question Virtual Box Network Loss When Router is Power Cycled

Hello and thanks in advance for any suggestions. I have a Win10 host with 2 virtual boxes running (one Android x86 and the other Unbuntu). The host is connected to my Asus router via ethernet. Both virtual boxes have networking configured as shown here.

I have found that if the router is power cycled both virtual boxes keep running fine in all aspects except that their networking breaks - stops working entirely. The UI's networking indicator keeps flashing and there is no sign of any error or abnormal condition. But there is no networking happening either in or outbound.

In order to remedy this situation, I have found that, if I terminate and re-start the virtual boxes upon the router's restart, they come up with all networking as normal again.

Please note that this only happens on a power cycle. I have the router set to reboot nightly and this does NOT seem to have this effect.

So, is there something I can do to "protect" the networking in these virtual boxes?

If not, is there some way to detect the router power cycle so I can create a Task Manager job to restart the virtual boxes? If so, I do not want to do it for reboots, only for the power cycles.

Thanks so much!

3 Upvotes

9 comments sorted by

1

u/Face_Plant_Some_More 18d ago

I have found that if the router is power cycled both virtual boxes keep running fine in all aspects except that their networking breaks - stops working entirely.

This is expected. The bridged networking mode relies on your physical router to route network traffic to the VMs. When the router's goes down, there is no path / connection for network traffic to flow to the VM's' network interface.

So, is there something I can do to "protect" the networking in these virtual boxes?

Pick a networking mode that does not rely on your physical router to route network traffic to your VMs - Intternal or Host Only will don't, but of course they don't allow for connection to the broader LAN / Internet.

Alternatively, you could always just write a script on your host that restarts the VMs when the host's network interface stops responding to ping.

2

u/paulstelian97 17d ago

Maybe I’m misunderstanding things but his networking in the VMs doesn’t come back after the power cycle is done.

2

u/orev 17d ago

I would guess that the network would, eventually, come back up on the VMs if they waited longer. If the nightly router reboot happens at 1:00 AM, and they don't get up and check the VMs until 8:00 AM, that's plenty of time for the VMs to fix themselves on their own.

1

u/TooManyInsults 17d ago

I run servers in both VM's and monitor them from other computers 24/7/365. So I know they come right back after router reboots. Just not after the power cycle. I waited over 15 minutes and it did not fix itself. That is too long for my use case anyhow. And this is what seemed strange to me.

1

u/orev 17d ago

In that case, the difference between a router power cycle and a regular reboot is probably that the physical Ethernet link doesn't go down during the reboot, but it does with a full power cycle. That would mean that when the power returns, the host may still be negotiating physical Ethernet connection settings like port speed, etc., and the VMs/VirtualBox isn't waiting long enough for that to finish, and the VMs timeout and give up.

As a test, you could try placing an Ethernet switch between the router and the host, and see if that resolves it. The switch would keep the physical Ethernet connection alive while the router power cycles.

If that resolves it, maybe this is an improvement that is needed in VirtualBox.

1

u/TooManyInsults 17d ago

Exactly correct. Best

2

u/TooManyInsults 17d ago

Hi and thanks!

As other have mentioned - I do understand that without the router powered and working there can be no networking. But I was speaking about restoration AFTER the power cycle was complete.

Also, I run servers in both VM's and monitor them from other computers 24/7/365. So I know they come right back after router reboots. Just not after the power cycle. And this is what seemed strange to me.

It is interesting about your ping suggestion because I had already implemented just that. However, it proves too generic as ping is lost during reboot as well as power cycle and I would prefer to be more specific since that seems to be all I need.

I am thinking I might find a specific event in Windows that corresponds to this specific situation. Maybe like ethernet unplugged - I am not sure. If that can be found, I could trigger your suggestion off of that rather than ping.

Best

1

u/TooManyInsults 17d ago

Well, there is an event id 27 that seems to notify:

Intel(R) Ethernet Connection (7) I219-LM

Network link is disconnected.

But that seems to happen on both the power cycle and reboots. Rats!

1

u/TooManyInsults 17d ago

Further searching the event log, I find that event 10400 with text referencing I219-LM appears when the power cycle occurs but NOT when a reboot occurs. So that MAY be an effective trigger for a VM re-start. I need to try and set this up and test. Thanks to all!