Issue with nat network not starting

Discussions related to using VirtualBox on Windows hosts.
Post Reply
jimosim
Posts: 3
Joined: 10. Sep 2021, 14:15

Issue with nat network not starting

Post by jimosim »

Hello, this is my first post, I searched on the forum but could not find anything about this.
I am using VirtualBox Version 6.1.26 r145957 (Qt5.6.2)

I have a use case where I need my VMs to communicate to each other, and I want to connect to them from my Windows host. So I created a Nat Network and assigned it to my 2 VMs (Ubuntu and Debian), I can ssh between them so everything is working. In both VMs I set up a static IPv4 address.
I have created some 2 port forwarding rules to be able to connect to them via ssh:

Code: Select all

>vboxmanage list natnets
NetworkName:    natnet1
IP:             10.0.2.1
Network:        10.0.2.0/24
IPv6 Enabled:   No
IPv6 Prefix:    fd17:625c:f037:2::/64
DHCP Enabled:   Yes
Enabled:        Yes
Port-forwarding (ipv4)
        ssh debian:tcp:[10.0.2.5]:2222:[10.0.2.5]:22
        ssh ubuntu:tcp:[10.0.2.4]:2222:[10.0.2.4]:22
loopback mappings (ipv4)
        127.0.0.1=2
But for some reason I cannot connect to them. Looks like my Windows host is not on the same network:

Code: Select all

>ipconfig

Configuration IP de Windows

....

Carte Ethernet VirtualBox Host-Only Network :

   Suffixe DNS propre à la connexion. . . :
   Adresse IPv6 de liaison locale. . . . .: fe80::1fd:5739:1c69:1fc6%12
   Adresse IPv4. . . . . . . . . . . . . .: 192.168.190.1
   Masque de sous-réseau. . . . . . . . . : 255.255.255.0
   Passerelle par défaut. . . . . . . . . :

....
If I change the configuration of the host only adapter in the Host Network Manager and assign to it a static IP on the same network, then I can connect to the host from the guest.

If I change the port forwarding rule to bind the host on 127.0.0.1, then I can connect to the guest from the host.

Moreover, I cannot start/stop the nat network from the command line:

Code: Select all

>vboxmanage natnetwork start --netname natnet1
VBoxManage.exe: error: Cannot start DHCP server because it is already running (pid 000024c4)
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), component DHCPServerWrap, interface IDHCPServer, callee IUnknown
VBoxManage.exe: error: Context: "Start()" at line 482 of file VBoxManageNATNetwork.cpp
VBoxManage.exe: error: Failed to start network

>vboxmanage natnetwork stop --netname natnet1

>vboxmanage natnetwork start --netname natnet1
VBoxManage.exe: error: Cannot start DHCP server because it is already running (pid 000024c4)
VBoxManage.exe: error: Details: code VBOX_E_OBJECT_IN_USE (0x80bb000c), component DHCPServerWrap, interface IDHCPServer, callee IUnknown
VBoxManage.exe: error: Context: "Start()" at line 482 of file VBoxManageNATNetwork.cpp
VBoxManage.exe: error: Failed to start network
This behaviour does not change if the VMs are up or down.
I already did this configuration in the past and it always worked! What am I doing wrong? Thank you in advance!
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Issue with nat network not starting

Post by scottgus1 »

jimosim wrote:I need my VMs to communicate to each other, and I want to connect to them from my Windows host. So I created a Nat Network
NAT Network does not easily facilitate communication from the host OS without port forwarding. It behaves like a router, with the host on the WAN side subject to all the restrictions a computer on the WAN side of a router would be subject to. See Virtualbox Networks: In Pictures: NAT network

To put the host OS and the VMs on the same network, use Host-Only or Bridged. Or open ports in the NAT Network.

As the first post is a bit too confusing with the two different network types interspersed, please pick one or the other network type and try the usual steps related to just that type of Virtualbox network.
jimosim
Posts: 3
Joined: 10. Sep 2021, 14:15

Re: Issue with nat network not starting

Post by jimosim »

scottgus1 wrote:
To put the host OS and the VMs on the same network, use Host-Only or Bridged. Or open ports in the NAT Network.
Thank you for your answer. I already opened ports with port forwarding:
jimosim wrote: I have a use case where I need my VMs to communicate to each other, and I want to connect to them from my Windows host. So I created a Nat Network and assigned it to my 2 VMs (Ubuntu and Debian), I can ssh between them so everything is working. In both VMs I set up a static IPv4 address.
I have created some 2 port forwarding rules to be able to connect to them via ssh:

Code: Select all

>vboxmanage list natnets
NetworkName:    natnet1
IP:             10.0.2.1
Network:        10.0.2.0/24
IPv6 Enabled:   No
IPv6 Prefix:    fd17:625c:f037:2::/64
DHCP Enabled:   Yes
Enabled:        Yes
Port-forwarding (ipv4)
        ssh debian:tcp:[10.0.2.5]:2222:[10.0.2.5]:22
        ssh ubuntu:tcp:[10.0.2.4]:2222:[10.0.2.4]:22
loopback mappings (ipv4)
        127.0.0.1=2
I don't think I can use host-only or bridged, I need the VMs to communicate between them, not sure I can do it with these network types?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Issue with nat network not starting

Post by scottgus1 »

jimosim wrote:I don't think I can use host-only or bridged, I need the VMs to communicate between them,
Did you look at the rest of the Pictures tutorial?
jimosim wrote:I already opened ports with port forwarding:
Sorry, I missed that before.
jimosim wrote:Port-forwarding (ipv4)
        ssh debian:tcp:[10.0.2.5]:2222:[10.0.2.5]:22
        ssh ubuntu:tcp:[10.0.2.4]:2222:[10.0.2.4]:22
These port forwarding include a forced 'host' source IP address of 10.0.2.5 or 10.0.2.4. If your host computer's IP address is not either of these, then the port forward rule won't match and SSH won't get through. If your host computer's IP address is one of them then it is not the other, and one of the VMs won't be contactble.
Virtualbox Networks: In Pictures: NAT network wrote:When opening a port, you will have to pick not only the port number but also which guest's IP address should receive the chosen outside network traffic.
The 'host' IP address is not needed.
jimosim
Posts: 3
Joined: 10. Sep 2021, 14:15

Re: Issue with nat network not starting

Post by jimosim »

scottgus1 wrote:
jimosim wrote:Port-forwarding (ipv4)
        ssh debian:tcp:[10.0.2.5]:2222:[10.0.2.5]:22
        ssh ubuntu:tcp:[10.0.2.4]:2222:[10.0.2.4]:22
These port forwarding include a forced 'host' source IP address of 10.0.2.5 or 10.0.2.4. If your host computer's IP address is not either of these, then the port forward rule won't match and SSH won't get through. If your host computer's IP address is one of them then it is not the other, and one of the VMs won't be contactble.
That's what I did wrong, the host IP address :) I changed it to the correct one, now it's working, thank you!
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Issue with nat network not starting

Post by scottgus1 »

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