Host --> Guest connection is not working on different network

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Mirjana
Posts: 5
Joined: 12. May 2022, 09:23

Host --> Guest connection is not working on different network

Post by Mirjana »

Hi,

I have Virtualbox on Windows 10, VMs are Linux with static IPs.

Everything is setup and working on one network (home):

- Guest to Guest conn works
- Guest to Internet conn works
- Host to Guest conn works

But when laptop is connected to another network (office), Host does not see Guest:

- Guest to Guest conn still works
- Guest to Internet conn still works
- Host to Guest conn DOES NOT WORK (guest IP cannot be pinged)

Tried to install Microsoft loopback adapter with the same IP laptop gets at home network, but no luck.

Any idea please?

Kind regards,
Mirjana
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Host --> Guest connection is not working on different network

Post by scottgus1 »

Right-click the VM in the main Virtualbox window's VM list, choose Show in Explorer/Finder/File Manager. Zip the VM's .vbox file (not the .vbox-prev file), and post the zip file, using the forum's Upload Attachment tab. (Configure your host OS to show all extensions if the folder that opens does not show a .vbox file.)

Please provide two sets of the following information, one set at home, the other set at the office:
  • In the Windows OS, open a Command Prompt and run ipconfig /all.
  • In the Linux OS, open a Terminal and run ifconfig or ip address. Post the command output.
  • In both host and VM Windows OS's, ping 8.8.8.8.
Mirjana
Posts: 5
Joined: 12. May 2022, 09:23

Re: Host --> Guest connection is not working on different network

Post by Mirjana »

Hi,

Thank you very much for the answer.
Everything is attached.

Please let me know if there is any info I can provide.

Kind regards,
Mirjana
Attachments
OFFICE SETTINGS.zip
(228.71 KiB) Downloaded 6 times
HOME SETTINGS.zip
(131.04 KiB) Downloaded 8 times
20220513_VirtualBox_Host_Gust_ConnIssue.zip
(10.66 KiB) Downloaded 5 times
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Host --> Guest connection is not working on different network

Post by scottgus1 »

Thanks for the info!

Your VMs have two networks, Bridged and NAT.

The home network is 192.168.1.#/24, and the office is 192.168.0.#/24. The VM's ifconfig shows that at home or in office the IP remains at 192.168.1.114. I couldn't tell if the VM is a static or DHCP IP address. The third octet confict is what's getting in the way with comms from host to guest at the office.

The guests can still connect to each other because they (I presume) still have the 192.168.1.# range. Multiple ranges can theoretically and sometimes practically exist on the same network. The different ranges cannot talk to each other, though, if the netmask blocks the comms.

The reason the VM continues to get internet and ping still works in the office, is because of the NAT interface. NAT does not depend on the host's or the network's IP address ranges.

See Virtualbox Networks: In Pictures. Your VMs have both a direct link to the LAN through Bridged, and a connection through a "router" via NAT.

You must either allow the VMs to get 192.168.0.# addresses at the office, or you'll need to take the VMs off Bridged to the LAN and put them on Host-Only. A group of Host-Only VMs can always talk to the host, barring other things getting in the way, and you can take the VMs aywhere, and comms will still be possible between each other and the host. NAT will still allow internet in the VMs. With Host-Only, other computers on the LAN won't get access to the VMs, though, unless you open ports through the NAT interfaces.
Mirjana
Posts: 5
Joined: 12. May 2022, 09:23

Re: Host --> Guest connection is not working on different network

Post by Mirjana »

Hi,

Thanks so much for your effort to answer me.

All VMs are on static IPs.
I tried to put VM on Host Only, with and without Adapter 2 as NAT, but cannot ping guest machine from the host.

Please let me know how to 'allow the VMs to get 192.168.0.# addresses at the office'?

Kind regards,
Mirjana
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Host --> Guest connection is not working on different network

Post by scottgus1 »

Mirjana wrote:how to 'allow the VMs to get 192.168.0.# addresses at the office'?
Since your home and office are on two different network IP ranges, you have two choices:

Undo this:
Mirjana wrote:All VMs are on static IPs.
in other words make the VMs dynamic, getting IPs from DHCP. You'd probably have to access the VMs through their network names, instead of IPs, since the IPs could change when served from DHCP.

Or, make both home and office on the same network IP range. If you can change the whole home network to 192.168.0.#/24, same as the office, and set the VMs' static IPs to 192.168.0.# also, then the VMs would connect in home or office (provided you're not also facing the Bridged vs Wi-Fi issue mentioned in the Pictures tutorial Bridged section at the office).

Alternatively:
scottgus1 wrote:take the VMs off Bridged to the LAN and put them on Host-Only
To do this you'd also have to change the VMs' static IPs to match the Host-Only network range, which is 192.168.56.#/24, according to your host's 'ipconfig /all'. Please note that on Host-Only only the host can access the VMs freely; the rest of the home or office network LANs cannot. If full access from the LAN is required, then you'd have to stay on Bridged.

Basically, the static IPs are getting in the way, because the net mask of /24, or 255.255.255.0, does not permit any of the first three sets of numbers in the IP addresses to be different. In your case you have three different third numbers: 0, 1, and 56. You'll have to switch something as above to get good network at home or office.
Mirjana
Posts: 5
Joined: 12. May 2022, 09:23

Re: Host --> Guest connection is not working on different network

Post by Mirjana »

Thank you very much.

From what I understood, I chose the option to change VirtualBox Host-Only address from 192.168.56.#/24 to 192.168.1.#/24 so it can match static IPs of VMs. I did not want to change all static IPs as there are applications set up on these IPs, especially inter-connectivity among apps.
Internet should be off, Adapter1 should be Host-Only and HOST --> GUEST connection works.
Will work on all other tests to check inter-comms. So far so good.

Kind regards,
Mirjana
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Host --> Guest connection is not working on different network

Post by scottgus1 »

Mirjana wrote:change VirtualBox Host-Only address from 192.168.56.#/24 to 192.168.1.#/24
Actually there is a reason not to do this: You already have a 192.168.1.# network, your physical home LAN. Having two networks on the same computer with the same IP range might cause some interesting problems. Just a point to be aware of if things go south one day.
BillG
Volunteer
Posts: 5104
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Host --> Guest connection is not working on different network

Post by BillG »

@Mirjana,

Rather than asking questions in a VirtualBox forum, perhaps you should look at a basic guide to IP networking. The questions you are asking have nothing to do with the VirtualBox and everything to do with basic IP networking. The answers would be exactly the same if you were talking about a PC or any other device which uses IP networking.

Scott is very patient and helpful, but these questions are simply not VirtualBox questions.
Bill
Mirjana
Posts: 5
Joined: 12. May 2022, 09:23

Re: Host --> Guest connection is not working on different network

Post by Mirjana »

Thank you very much Scott, it helped a lot. Thanks for your patience for ignorant question, asking wrong question in this forum or choose the wrong forum for valid question :(
Will keep Virtualbox on 192.168.56.# and change static IPs in VMs.
My deep apologies for intruding this forum.

Kind regards,
Mirjana
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Host --> Guest connection is not working on different network

Post by scottgus1 »

You're definitely not intruding! It was a good question!

While this question ultimately did come down to misconfiguration of the network IP ranges, we did need to check that the Virtualbox networks were working correctly, and confirm just what network types were being tried. There are nuances to the network types offered by Virtualbox that are not immediately apparent at times to the users. So it's perfectly OK and good to ask "what's wrong with the network in my VMs" here first. Once we confirm that the Virtualbox network is set according to the user's needs and is working, then we can see if there is an error in the user's configuration.

As Bill mentioned, you may wish to do some research in a network tutorial site to see why the various IP configuration setups you had weren't working (especially how the netmask influences the configuration) or why having two networks on the same PC with the same IP range was going to cause trouble. That will help you in further Virtualboxing and other networking projects.
Post Reply