Networking problem

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Memento
Posts: 9
Joined: 13. Sep 2022, 10:53

Networking problem

Post by Memento »

I'm on Windows 7 host with Linux guest in a VM. I want to connect VM to the internet. When I choose 'Bridged Adapter' in VM's Network settings, I don't get an option to select my broadband connection from mobile carrier, which is the source of internet. I get 'Invalid settings detected' message at the bottom. What should I do?
I can select only physical network card there - if I enable it that is. But it is disabled, since I don't use it at the moment and it is not a source of internet.

I tried selecting 'Host-only Adapter' in Network settings, but when I try to share internet from mobile carrier I get 'An error occurred when enabling internet connection sharing. (null)' Windows message.

I'm at a loss. Please guide me through this.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Networking problem

Post by mpack »

Are you talking about a USB 4G dongle modem?

Bridged requires an Ethernet or WiFi LAN adapter to bridge to. A USB modem is not a LAN adapter and so will not work. Even if you got the modem connected to the guest OS, you'd need Linux drivers for it.

You have to stick to NAT or NAT network, or get yourself a LAN router that you plug the USB dongle into. Or just get an LTE router (one that accepts the SIM card directly).

Host-only networking is definitely not how you get Internet. You get host (only), hence the name. You also should not be enabling any kind of host OS Internet sharing.
Memento
Posts: 9
Joined: 13. Sep 2022, 10:53

Re: Networking problem

Post by Memento »

mpack wrote:Are you talking about a USB 4G dongle modem?

Bridged requires an Ethernet or WiFi LAN adapter to bridge to. A USB modem is not a LAN adapter and so will not work. Even if you got the modem connected to the guest OS, you'd need Linux drivers for it.
Yes, its an USB 4G modem. As for passing USB modem directly to Linux, I can, and used to do it as a last resort. Even though I don't have proper Linux drivers, I managed to operate it with just terminal and some esoteric commands I have saved. The problem here is that in that case I lose internet on my host, which makes the whole setup unusable.
mpack wrote:You have to stick to NAT or NAT network, or get yourself a LAN router that you plug the USB dongle into. Or just get an LTE router (one that accepts the SIM card directly).
NAT has several limitations as described in the docs, and I would rather have proper internet in a VM. Getting a router is not an option in my case as well. Not not only it will require money spending, but also excessive and unneeded, since I have only one PC. I don't need to stick USB modem into router when I can directly stick it into PC. And buying router just to get VM working doesn't make any sense. Though I can (and did before) install virtual router in a VirtualBox (pfSense), but that's too excessive and unneeded for my workflow.
mpack wrote:Host-only networking is definitely not how you get Internet. You get host (only), hence the name. You also should not be enabling any kind of host OS Internet sharing.
Could you elaborate? Because I did manage to make 'Host-only adapter' work myself eventually, already after I posted a question. Turned out I had 'Windows Firewall' service disabled and that prevented ICS to start. Now Internet Sharing works and Linux VM got internet.

However I encountered different problem now: for some reason I randomly lose internet in about an hour or two (on both host and guest), I can't figure out the pattern when exactly it happens. What could be the reason? Is it possible to track it down?
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Networking problem

Post by scottgus1 »

See Virtualbox Networks: In Pictures for the different Virtualbox network types.
Memento wrote:I would rather have proper internet in a VM.
NAT/NAT Network does give you internet in the VM. I've tried it many times. Perhaps if you explain this:
Memento wrote:NAT has several limitations as described in the docs
we might be able to explain how to get done what you want.

The reason Bridged won't work but NAT will in your case is because (see the Pictures tutorial) Bridged puts the VM network connection on the host's LAN as a separate independent connection that goes around the host's internet connection. So there has to be a LAN there. But the USB modem isn't a LAN, so Bridged cannot connect.

However, NAT goes through the host's internet connection, and the USB modem is that connection. So NAT works.

Host-Only is designed to be connected between the VM and the host only. So while it could be possible to use the host's ICS on it, there's no telling what will happen, and it's not a supported connection, so we won't know how to troubleshoot it.
Memento wrote:I can (and did before) install virtual router in a VirtualBox (pfSense)
The USB modem can connect via NAT to the router VM, and then pass internet to the VM and host through a common Host-Only network. The pfSense VM needn't be high resources, and this may be a really good work-around to avoid buying a physical router.

If you can explain what goes wrong with your setup when using NAT, we could help get you running.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Networking problem

Post by mpack »

Memento wrote:I would rather have proper internet in a VM. Getting a router is not an option in my case as well. Not not only it will require money spending, but also excessive and unneeded, since I have only one PC.
NAT gives you proper Internet, far more so than the "Internet sharing" that you tried.

What NAT does not give you is full networking. If you want the full power of a network then you need a network, not just a modem. And btw you don't just have one PC, you have a physical PC plus at least one virtual PC, plus a modem all of which you want to share on a network. The only way I know for multiple PCs to get full Internet access through a single gateway is to have a LAN, and to have a router or router-software somewhere on that LAN.

Frankly, you should stick to NAT unless you can name a specific feature that it would not provide.

Also: I'd claim that a router is a necessity in a modern home, not a luxury. How else does a multitude of tablets, smart phones and smart TVs, doorbell cameras etc get WiFi access? It's true that it doesn't always have be a physical device, but it sure works better that way.
Memento
Posts: 9
Joined: 13. Sep 2022, 10:53

Re: Networking problem

Post by Memento »

scottgus1 wrote:See Virtualbox Networks: In Pictures for the different Virtualbox network types.
Thanks, that does help to understand networking modes in VirtualBox better.
scottgus1 wrote:Perhaps if you explain this:
Memento wrote:NAT has several limitations as described in the docs
I was referring to "NAT Limitations" part of manual:
There are some limitations of NAT mode which users should be aware of, as follows:
  • ICMP protocol limitations. [...]
  • Receiving of UDP broadcasts. [...]
  • Some protocols are not supported. [...]
  • Forwarding host ports below 1024. [...]
Especially, not supported protocols and port forwarding limitations. Its not just browsing that I need internet for. I'm planning to experiment and run different internet-oriented apps and services in this VM, and I don't know what requirements regarding networking they might have or what kind of wall I might unexpectedly hit in the future because of these limitations. That is why I would rather have proper networking, than crippled NAT.
mpack wrote:I'd claim that a router is a necessity in a modern home, not a luxury. How else does a multitude of tablets, smart phones and smart TVs, doorbell cameras etc get WiFi access?
I agree with that - for someone who has such use case as you described. But I don't. I don't have neither doorbell cameras, nor smart TVs or smartphones. Single PC does not need physical router. Having router means to have another point of failure, it needs to be properly configured, regularly get security updates etc. What for do I need all this hassle? On top of it, quality LTE router costs several hundreds of bucks. Its a waste of money and time to maintain for almost no gain. It's a complete overkill in my current use case. What makes it even harder for me to justify buying new router is that I already have Wi-Fi router that collects dust, its somewhat old, but it works, it's just doesn't have USB port unfortunately.

I could go with NAT for now, as long as everything works, but I feel like its a less than ideal solution that might backfire in the future.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Networking problem

Post by scottgus1 »

Memento wrote:I was referring to "NAT Limitations" part of manual:
Ah, good, that makes things clear.
Memento wrote:I'm planning to experiment and run different internet-oriented apps and services in this VM,
Generally, NAT behaves like a router. Everything on the LAN side (where the VM is) can get out to the WAN side (the host, the host's LAN and the internet). The stuff on the WAN side can't get into the LAN (VM) side uninvited unless ports are opened.

That said, and as long as the more esoteric quid pro quos in that NAT Limitations list aren't touched, you shouldn't have trouble getting your apps to reach the internet through NAT.

I do have another idea, though: From the tutorial, Bridged works when there is a wired LAN attached to the computer. And when Bridged is working, the VM and the host can communicate on the LAN IP address range. I did an experiment some time ago to see just how little of an actual LAN was required to get Bridged communication between host and VM to work. What I recall discovering (and I'm moving houses now so my computers are all broken down so I can't re-test to make sure just now) is that a host and VM with static IP addresses in compatible range, Bridged via the host's Ethernet adapter, would communicate together as long as the Ethernet adapter was up, that is, connected to something Ethernet, anything, regardless of that something's IP settings, just as long as the adapter's lights were blinking.

If the above remains correct, then some cobbling might work if this is also true: Does your USB modem come with instructions on how you could feed internet from the modem out through the computer's Ethernet port to a LAN of computers, so they could all have internet from the USB modem?

If so, here is something that could be done:
Find something to plug into the host's Ethernet adapter: an unmanaged switch, an old Raspberry Pi, anything to start the Ethernet adapter's blinkenlichten. No need to set any IP settings on the attached device.
Follow the instructions for the modem to feed internet out the host's Ethernet adapter. See if your host can get internet.
If so, set the VM to Bridged, pointing at either the host's Ethernet adapter or whatever the USB modem instructions made.
Set the VM to a static IP address, netmask and gateway compatible with the USB modem IP range. See if the VM can get internet.

Another alternative, if your host has two working Ethernet adapters:
Follow the instructions for the modem to feed internet out one of the host's Ethernet adapters. See if your host can get internet.
Set the VM to Bridged, pointing at the other host Ethernet adapter.
Go into the Properties of the 'other' host Ethernet adapter that the VM is Bridged to, and disable all the bindings except the Virtualbox Bridged binding:
Image
Plug a network wire between the two network adapters.
Set the VM to a static IP address, netmask and gateway compatible with the USB modem IP range. See if the VM can get internet.
Memento
Posts: 9
Joined: 13. Sep 2022, 10:53

Re: Networking problem

Post by Memento »

I don't have two Ethernet adapters, so I can't test that setup, but I tested your first suggestion.
scottgus1 wrote:host and VM with static IP addresses in compatible range, Bridged via the host's Ethernet adapter, would communicate together as long as the Ethernet adapter was up, that is, connected to something Ethernet, anything, regardless of that something's IP settings, just as long as the adapter's lights were blinking.
Yes, you appear to be right. I turned on Ethernet (connected to my old router), set up "Bridged Adapter" in VM's Network settings. And indeed host and VM can see each other in LAN with just manually set static IPs, without router (which is not configured and not even in the same IP range).
scottgus1 wrote:Does your USB modem come with instructions on how you could feed internet from the modem out through the computer's Ethernet port to a LAN of computers, so they could all have internet from the USB modem?
My modem doesn't have any special instructions, so I just shared internet to Ethernet adapter with Windows' ICS. And yes, internet appears in a VM with this Bridged setup. Also, I didn't test, but now I think that "Bridge Connections" option in Ethernet adapter's right click menu in Windows probably should also pass internet directly from modem. Other than that I don't know how else to pass internet directly from modem plugged into Windows machine into LAN.

But that's good enough for me, as long as everything works. Which it seems it does, so I'm not gonna push it further for now.

Thank you very much for help, scottgus1 and mpack!
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Networking problem

Post by scottgus1 »

Great! Glad you're up and running.
Post Reply