Network "NAT" mode and connect to the VM.

Discussions related to using VirtualBox on Windows hosts.
Post Reply
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Network "NAT" mode and connect to the VM.

Post by hack3rcon »

Hello,
I installed a Linux VM on VirtualBox and the network setting is "NAT". I defined port forwarding and can connect to my VM via the Putty, but I want to scan my VM from Windows via Nmap. Is it possible via "NAT" ?
When I used "127.0.0.1" as target in the Nmap then it scan my host OS and not guest OS.

Thank you.
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: Network "NAT" mode and connect to the VM.

Post by scottgus1 »

If you can 'Nmap' one PC from another PC then
    if you can Nmap through a router then
        open ports in NAT required by Nmap
        Nmap-scan other PC via 127.0.0.1:portnumber
    end if
end if
Virtualbox Networks: In Pictures: NAT
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: Network "NAT" mode and connect to the VM.

Post by hack3rcon »

scottgus1 wrote:
If you can 'Nmap' one PC from another PC then
    if you can Nmap through a router then
        open ports in NAT required by Nmap
        Nmap-scan other PC via 127.0.0.1:portnumber
    end if
end if
Virtualbox Networks: In Pictures: NAT
I did it too but Nmap can't see my VM:
VB-1.PNG
VB-1.PNG (33.55 KiB) Viewed 1589 times
I can ping the VM:
VB-2.PNG
VB-2.PNG (12.59 KiB) Viewed 1589 times
But Nmap can scan the VM:
VB-3.PNG
VB-3.PNG (5.84 KiB) Viewed 1589 times
What the problem?
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: Network "NAT" mode and connect to the VM.

Post by scottgus1 »

First, if you are using plain NAT, the 'Pictures' tutorial will have informed you that you do not need to put host IP address or guest IP address in a NAT port forward. Added but unnecessary information may cause trouble.

If you can ping either way over a Virtualbox network, then the network is working and other programs' settings are interfering.

You are essentially trying to Nmap a computer behind a router from another computer on the internet, and you have control over the router.

Virtualbox is only providing the router and the target computer. Ask on a Nmap forum how to Nmap a computer behind a router. Apply the same methods to the NAT port forwarding and guest OS.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: Network "NAT" mode and connect to the VM.

Post by hack3rcon »

Thus, in this situation, the only option is using "Host-only Adapter" ?
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: Network "NAT" mode and connect to the VM.

Post by scottgus1 »

Host-Only is a private channel between host and connected guests. There is no 'router' or port forwarding in Host-Only. No internet either. Anything one can do over a regular network one could do with Host-Only.
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: Network "NAT" mode and connect to the VM.

Post by fth0 »

hack3rcon wrote:But Nmap can scan the VM: [...]
No, it cannot. (Re-)read the content of the picture you posted.
hack3rcon wrote:What the problem?
That you don't seem to know how to use NMAP. ;)

Try nmap -p 5060 127.0.0.1.
Post Reply