How to access a "NAT Network" from host?

This is for discussing general topics about how to use VirtualBox.
Locked
mcon
Posts: 7
Joined: 2. Nov 2014, 17:56

How to access a "NAT Network" from host?

Post by mcon »

I have a few (linux) hosts on a "NAT Network" (default: 10.0.2.*).
This works as advertised.
Problem is I would like my host (Win7) to join, somehow this sub-net.
I haven't found a way to do it (aside from setting up a parallel "HOST Only" network with each and all my clients).
Did I miss something?
NOTE: I usually use "Bridged", but I cannot do it here because I have a single IP address assigned (to the HOST, of course).

I need:
  • to be able to reach the Internet from the host.
  • to be able to reach the Internet from clients
  • to be able to reach clients from the host.
  • reaching host from clients is not necessary.
  • reach a client from another client is not necessary.
How should I set my Network?

TiA
Mauro
Perryg
Site Moderator
Posts: 34369
Joined: 6. Sep 2008, 22:55
Primary OS: Linux other
VBox Version: OSE self-compiled
Guest OSses: *NIX

Re: How to access a "NAT Network" from host?

Post by Perryg »

Your best approach is to use the two adapter solution. One to NAT and one to Host-Only.
BillG
Volunteer
Posts: 5102
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: How to access a "NAT Network" from host?

Post by BillG »

NAT is an Internet standard procedure. It was designed to allow machines on a private LAN to connect to the Internet but be invisible from the Internet. For this reason it specifically prevents access to the "private" machines from the "public" side.

If you use bridged mode, the host and guests are all in the same private LAN.
Bill
JMD-tech
Posts: 3
Joined: 21. Dec 2021, 01:11

Re: How to access a "NAT Network" from host?

Post by JMD-tech »

Was bitten by this 2 years ago. For the sake of simplicity i wanted to have all my guests on the same subnet as the VirtualBox interface of the host, to SSH or VNC into any of them. And also have them see eachother, and access Internet (client-only).
As i have about 10 guest VMs for development, on a laptop host that frequently changes from a network to another, i couldn't use bridging (wanted to use fixed-IPs for all the guests for easy access from host).

NAT network was nearly perfect, except no communication between guests and host.
Host-only network was nearly perfect, except no internet access for the guests.

I eventually managed to get a working configuration with one minimal Debian VM acting as DNSmasq with two interfaces, and a bridge of those two interfaces. Well, until last week i just toggled of the virtualbox network interface because of conflict with another software, but when re-enabling it, host to guest access wouldn't work at all anymore.

After 2 hours managed to get back either internet access to guests, or guests access between them and not to the host.

Might maybe try as a last resort Host-Only for all guests, and the gateway VM doing NAT, albeit it'd be very ugly to have both two NATs daisy-chained, and the guests having different addresses betwwen them and from the host.

Virtualbox works wonderful, if only it would have a rework of its lousy network, maybe to allow much more sophisticated things, but for basic usage it would be perfect if only (an option of) NAT-network would allow guest<=>host communication.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: How to access a "NAT Network" from host?

Post by scottgus1 »

'Tis an old post resurrected, but JMD-tech may have a slight disconnect over where the problem lies. Though there is not enough information in JMD's post for a complete diagnosis.

Bridged is the optimum setup for easy access between the VM and the LAN. But things outside of Virtualbox's control can prevent Bridged from working.

See Virtualbox Networks: In Pictures: Bridged Adapter.
JMD-tech wrote:VMs for development, on a laptop host that frequently changes from a network to another,
I gather from usage of a laptop and different networks that Wi-Fi is being used.

If Bridged is connecting to a Wi-Fi adapter, then the Wi-Fi adapter drivers and the Wi-Fi access point firmware could interfere with Bridged. Technically, the Wi-Fi protocol does not allow Bridging. Some Wi-Fi adapter drivers and WAP firmware are lazy and don't implement the complete protocol. These situations allow Bridged. Strict drivers & firmware block Bridged. Virtualbox has absolutely no influence on what drivers or firmware are being used. Thus Bridged works in one host or place but not another.

Bridged always works on a properly-working wired Ethernet adapter.

Regarding the OP question: NAT and NAT Network act just like house routers. These network types, just like house routers, have port forwarding, which allow access to the VM from the host or internet. See these types in the linked "In Pictures" tutorial.

JMD-tech or others with further questions, please start a new topic for further discussion.
Locked