Is it possible internal connection from VM to Host while bridged network?

This is for discussing general topics about how to use VirtualBox.
Post Reply
Dito65
Posts: 5
Joined: 24. Nov 2023, 12:53

Is it possible internal connection from VM to Host while bridged network?

Post by Dito65 »

Hello to everyone,

I have a bridged Win7 VM (set up with IP 192.168.0.51) on a Debian host (whose IP is 192.168.0.50).
Win7 is accessed through RDP from others PC in the lan and is meant to share an application that operates on files stored on the host.

As the application on Win7 points to IP 192.168.0.50 in order to get to the needed files, I figure it out that this data traffic goes through the lan to the router and back to the same physical machine.

Is there any option to avoid this redundancy and get this specific traffic routed interally in the same machine?

Or am I wrong and this connection already works the way I want?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Is it possible internal connection from VM to Host while bridged network?

Post by mpack »

Dito65 wrote: 24. Nov 2023, 13:36 As the application on Win7 points to IP 192.168.0.50 in order to get to the needed files, I figure it out that this data traffic goes through the lan to the router and back to the same physical machine.
I don't believe that's how it should work. AFAIK the bridged driver attached to the local NIC acts like a switch. As such it should route the packet back without it ever reaching the physical network beyond.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Is it possible internal connection from VM to Host while bridged network?

Post by scottgus1 »

In addition to Mpack's thoughts above (maybe Virtualbox Networks: In Pictures: Bridged Adapter might help you visualize the extra Bridged "switch"):

You are able to access the data now, in the normal fashion that two physical PCs would do it. The only difficulty I could see with your existing setup is if the data going through the LAN is swamping the LAN and slowing other things down.

There is a Host-Only network you can add to the VM on a different VM network adapter. But the Host-Only network cannot be merged into the LAN network, it must remain separate, with different IP address range than the LAN. You'd have to change the service running on the VM to point to the host's Host-Only network adapter (defaults to 192.168.56.1) instead of the 192.168.0.50 you have now. Whether that's easy or difficult depends on your service, and whether that gives you faster access to the data can only be told by trying it.

If the VM accesses the data only by opening host files, not by reading/writing into host databases, you might be able to use Virtualbox Shared Folders, which is a separate data transfer channel through Guest Additions that does not go through the network. Again the speed will have to be experimentally determined. And the type of access to the host files may be a problem: Though Virtualbox Shared Folders are intended to act like a real shared folder, experience shows that they're only solidly reliable for copying files into and out of the VM.

If you're trying to solve a LAN speed problem, a faster switch may help, too, with less experimental setup.

(I'm not sure how this could be done, but a Wireshark trace on what's going through your LAN switch might be able to tell if the data is making it out to the LAN switch or only staying inside the Bridged "switch" generated by Virtualbox.)
Dito65
Posts: 5
Joined: 24. Nov 2023, 12:53

Re: Is it possible internal connection from VM to Host while bridged network?

Post by Dito65 »

scottgus1 wrote: 24. Nov 2023, 14:20 (maybe Virtualbox Networks: In Pictures: Bridged Adapter might help you visualize the extra Bridged "switch"):
That's really fantastic!
scottgus1 wrote: 24. Nov 2023, 14:20 There is a Host-Only network you can add to the VM on a different VM network adapter.....
I'll give a try and verify if this has benefits or not
scottgus1 wrote: 24. Nov 2023, 14:20 If the VM accesses the data only by opening host files, not by reading/writing into host databases ...
Actually I don't know much about this "management software" behaviour, not even the reason to develop Linux data handling and Windows user GUI, but I'm quite sure it's more complex than just "copying files"
scottgus1 wrote: 24. Nov 2023, 14:20 (I'm not sure how this could be done, but a Wireshark trace on what's going through your LAN switch might be able to tell if the data is making it out to the LAN switch or only staying inside the Bridged "switch" generated by Virtualbox.)
Clever suggestion!

Thanks so much!
Dito65
Posts: 5
Joined: 24. Nov 2023, 12:53

Re: Is it possible internal connection from VM to Host while bridged network?

Post by Dito65 »

mpack wrote: 24. Nov 2023, 14:11 I don't believe that's how it should work. AFAIK the bridged driver attached to the local NIC acts like a switch. As such it should route the packet back without it ever reaching the physical network beyond.
Actually this has sense 8)
Dito65
Posts: 5
Joined: 24. Nov 2023, 12:53

Re: Is it possible internal connection from VM to Host while bridged network?

Post by Dito65 »

Dito65 wrote: 24. Nov 2023, 16:28
mpack wrote: 24. Nov 2023, 14:11 I don't believe that's how it should work. AFAIK the bridged driver attached to the local NIC acts like a switch. As such it should route the packet back without it ever reaching the physical network beyond.
Actually this has sense 8)
Tested with Wireshark, no packet outside the physical machine :wink:
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Is it possible internal connection from VM to Host while bridged network?

Post by scottgus1 »

Dito65 wrote: 28. Nov 2023, 17:35 Tested with Wireshark, no packet outside the physical machine
Ha, that's interesting! Thanks for the results.

So you may already have the best setup. You could compare data throughput via Bridged vs Host-Only, but it looks like the data is staying off the LAN.
Dito65
Posts: 5
Joined: 24. Nov 2023, 12:53

Re: Is it possible internal connection from VM to Host while bridged network?

Post by Dito65 »

scottgus1 wrote: 28. Nov 2023, 17:44 So you may already have the best setup. ...
Now just want to try if there's any benefit having the VM on a dedicated raw SSD instead of a VDI file sharing the same HDD where Linux Host data are stored, but that's another story ...

Anyway thanks for help!
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Is it possible internal connection from VM to Host while bridged network?

Post by mpack »

Dito65 wrote: 29. Nov 2023, 11:32 Now just want to try if there's any benefit having the VM on a dedicated raw SSD instead of a VDI file
There will be a benefit to being on an SSD, but no benefit at all to being "raw". Raw I/O bypasses host file caching, why would that be a good thing?

In any case SSD can have a huge number of outstanding parallel I/O transaction (there being no seek latency), so the issue of "sharing the drive" is a non-sequiter.
Post Reply