Page 1 of 1
VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 19:22
by jayChandler
My Host OS is Windows 10 and i am running an Ubuntu Server 16-04 Guest VM. On my guest VM i have enabled Network Bridge and its working fine. I get a proper IP from the DHCP and both boxes can ping each other.
But now i have some services running on my HOST which want to make accessible via port forwarding to my VM.
I have added a second network adapter in NAT mode and added a rule
Host Ip: Blank
Host Port: 9042
Guest Ip: Blank
Guest Port: 9042
I want to redirect my HOSTS 127.0.0.1:9042 to my VMS 127.0.0.1:9042
This is the output from the log
NAT: Set redirect TCP 0.0.0.0:9042 -> 0.0.0.0:9042
I rebooted the VM several times but when i do
netstat -nap | grep 9042
The output is empty
Also trying
telnet 127.0.0.1 9042 ends up in Conection refused
What am i doing wrong here ? Is this not possible ?
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 19:35
by Perryg
If you are using bridged then you are not using vbox NAT and vbox NAT port forwarding only works in vbox NAT.
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 19:49
by jayChandler
And how can i acomplish what i want ?
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 19:53
by Perryg
Switch from bridged to NAT or add a second adapter in the guest set to NAT.
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 19:57
by jayChandler
Thats exactly what i have done!
I have added a second adapter with NAT
Primary Adapter is Bridged
Secondary is NAT
But forwarding does not work
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 20:01
by Perryg
Odd. Try temporarily disabling the adapter set to bridged and see what happens. If it still fails make sure you do not have a firewall issue that is blocking the port.
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 20:14
by jayChandler
Just not working
This are my settings! See my attachments
Anything wrong with my rules ?
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 5. Oct 2017, 20:27
by Perryg
What you provide does not really show an error but that is just the tip of the iceberg. Like I said you need to make sure the host is not blocking this with its firewall. Also I admit I am slightly confused with your first post when you say you want to make services on the host available to the guest.
But now i have some services running on my HOST which want to make accessible via port forwarding to my VM
This is not the way it normally works if I take this statement literally.
Re: VirtualBox bridged network and NAT port forwarding at the same time
Posted: 6. Oct 2017, 11:50
by mpack
It seems to be that this entire question is misplaced. If the VM is bridged to the physical network then it's a peer on the same network as the host, i.e. it's just two (or more) PCs networked together. Share services across that network the same way you'd do it if VMs were not involved.
As Perry has said, port forwarding is only applicable to NAT. NAT blocks every port by default, and forwarding is a way of creating exceptions to that. But if the VM is using bridged then it already receives everything on every port.