Port forwarding

Discussions related to using VirtualBox on Windows hosts.
Post Reply
Axell
Posts: 9
Joined: 12. Feb 2022, 18:54

Port forwarding

Post by Axell »

Hi there!!!
I still have some problems with RPD\SSH with NAT settings. There is no any problem with Bridge (it's very simple when all of the hosts in the same network).
So..... input still:
Host - Win 10 Pro x64;
VM Box - 6.1.32 r14920 (Qt5.6.2)
VM in VBox - WS2019

I want to RDP to my WS2019, my steps are:

1. WS2019, in Local Server management - Remote Desktop - Enable
2. I turn off Firewall to all networks (Domain, Private, Public) - all in "Firewall is off"
3. In System setting\Advanced system setting\Remote enable option: Remote Desktop "Allow remote connections to this computer", unchecked mark "Allow connections only from......(recommended)"
4. Network of my VM - NAT, address of my current mv: 10.0.2.15. From VM i have all that i want (internet, host and so on);
5. In Machine\settings\Display\Remote Display i check mark "Enable Server";
6. In port forward section i create record:
Name: RDP, Protocol: TCP; HOST IP: 127.0.0.1; Host Port: 3390; Guest IP: 10.0.2.15; Guest Port: 3389
7. I also install Extentions: Oracle VM VirtualBox Extention Pack 6.1.32r149290
8. I have only one network adapter in my VBox VM, with ip 10.0.2.15. Nothing else.
9. I try to

Code: Select all

telnet 10.0.2.15 3389
and

Code: Select all

telnet 10.0.2.15 3390 
and have nothing....

But i still can't rdp.
I try also mstsc 10.0.2.15:3389 and 10.0.2.15:3390

Port forwarding, firewall and RDP settings on screen below:

bandicam 2022-02-13 11-45-20-604.jpg
bandicam 2022-02-13 11-45-20-604.jpg (79.57 KiB) Viewed 6640 times
bandicam 2022-02-13 11-44-55-563.jpg
bandicam 2022-02-13 11-44-55-563.jpg (110.59 KiB) Viewed 6640 times
fth0
Volunteer
Posts: 5690
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Port forwarding

Post by fth0 »

Your mistake is to use 10.0.2.15 in your commands, use 127.0.0.1 instead:

You've configured two alternative RDP servers. You should be able to reach the RDP server of the guest OS via 127.0.0.1:3390, and the VirtualBox VRDP server via 127.0.0.1:3389. The latter will only work if your host OS doesn't have its own RDP server running on port 3389.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows, Linux

Re: Port forwarding

Post by scottgus1 »

Adding on a few more tidbits:

NAT behaves like a house router. See Virtualbox Networks: In Pictures. The private "LAN" IP address given to the VM (10.0.2.15) is hidden from the "WAN" side of NAT, same as a house router hides the 192.168.#.# IP addresses the router hands out on the house network from the internet. For NAT the VM is on the LAN (in fact the VM is the only device on NAT's LAN) and the host is part of the "internet" on NAT's WAN side.

If you wanted to remote into a computer in your house LAN from some computer out on the internet, you'd set up a port forwarding rule in your house router pointing at that computer's LAN IP address, then you'd access the house computer from the internet computer by accessing the public "WAN" IP address that your ISP gives you, and the port number in the port forwarding rule, not by accessing the house computer's LAN IP address:
public.ip.add.ress:portnumber < this will work
LAN.ip.add.ress:portnumber < this will fail

The same works for NAT. The host PC is part of the "internet", so cannot access the VM's IP address directly. You need to access through the NAT WAN IP address, which is the host's IP address. That's why you can't get at the VM through 10.0.2.15, and fth0 suggests to use 127.0.0.1, which is the 'loopback' address for the host to access its own self. And it is how the host accesses NAT's WAN side.

If you wanted to access the VM from another computer on your LAN, you'd point that computer at your host's LAN IP address, like the 192.168.#.# normally handed out by house routers.
Axell
Posts: 9
Joined: 12. Feb 2022, 18:54

Re: Port forwarding

Post by Axell »

Thanks for grean explanation!!! Just before that i thought that 10.0.2.** is just a subnet with a pool of ip addresses to which i can connect without any problems. Thanks a lot!!!! There is no records about 10.0.2.** in host network manager.
The main idea is that localhost (127.0.0.1) is a router to NAT VBox VMs with 10.0.2.** addreses

Another one question - why every comments from me in other posts look like a new posts to me???
BillG
Volunteer
Posts: 5106
Joined: 19. Sep 2009, 04:44
Primary OS: MS Windows 10
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows 10,7 and earlier
Location: Sydney, Australia

Re: Port forwarding

Post by BillG »

Axell wrote:
Another one question - why every comments from me in other posts look like a new posts to me???
If you want to add a comment to an exiting post, click on the big red POST REPLY message at the bottom of the post and type your reply in there. That always works for me!

If you are doing that but you still end up seeing it as a new post, start a new thread with its own title. This has nothing to do with a thread on port forwarding.
Bill
Post Reply