virtualbox port forwarding does not work
Another method is continue use one NAT adapter but use "127.0.0.1" as the port forwarding host IP. The port forwarding rule will be something like (you might add one for UDP also)
Protocol : TCP, Host IP : 127.0.0.1, Host port : 3000, Guest IP : "guest ip", Guest port : 3000
Then you can use 127.0.0.1:3000 to access the guest.
The loopback interface IP 127.0.0.1 is always online even the physical network is disconnect.
Related videos on Youtube
canoe
Updated on September 18, 2022Comments
-
canoe over 1 year
My Ubuntu is the guest OS running on a windows host. NAT is used and port forwarding has been added. All access to host on port 3000 should be forwarded to guest on the same port.
But that port can be only accessed on guest machine but not accessible from host machine.
With bridged network setting, there is no trouble. But my concern is that when I work offline(no internet connection) with my host machine, I can't access the guest via that port number any more. I've tried to disable the connection on host, then can't connect the port 3000.
What might be wrong with my installation and default NAT configuration(v4.3.20)?
-
Admin over 7 yearssimilar issue is when having nested VM running on Windows, that is VM ubuntu running VM ubuntu - normal portforwarding suddenly does not work
-
-
canoe over 9 yearsI am blocked at step 3). and can't ping the gateway 10.0.2.2 on the guest - "the destination host is unreachable".
-
Anbu over 9 yearsPing the Host Only Adapter's IP address not the NAT's one. What are the IP addresses that are configured to NAT & Host Only adapter? And your Host's Virtual Box Adapter's IP address
-
canoe over 9 yearsNAT CIDR:10.0.2.0/24, Host-Only adapter: 172.16.2.1/255.240.0.0, host's virtual box ip: 192.168.1.101/255.255.255.0. The ping from guest to host-only adapter and virtual box host returns network unreachable.
-
canoe over 9 yearsChanged. Then I reboot the guest linux. Something wired happens. Now guest eth0 has only an IPv6 ip, the previous v4 ip is gone. Guest IPs - eth0: fe80::a00:27ff:fe94:e29a/64, lo:127.0.0.1, lxcbr0: 10.0.3.1/24 virbr0: 192.168.122.1/24.
-
canoe over 9 yearsThe virtual box(host-only adapter) status shows cable connected.
-
canoe over 9 yearsThere is no such name on windows which has the host-only adapter. On linux, it is eth0. ifup eth0 takes about 10 minutes in linux to finish and has output like "DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7 (xid=0x64e25def). No DHCPOFFERS received. No working leases in persistent database - sleeping." Do I need to configure the dhcp server in virtual box?
-
canoe over 9 yearsMy trouble is when I use NAT, port 3000 is not accessible from host. access from guest machine to the same port has no issue.
-
canoe over 9 yearsOK. Adapter 1 is enabled and attached to 'NAT', the name field is grayed out and empty. Is this correct? now the guest OS has no connection to internet.
-
Eric Leung over 9 yearsWhen selected "NAT", the name field grayed out and empty is correct. When click advanced, is the cable connected ? What entry in Port Forwarding ?
-
canoe over 9 yearsCable is connected. When TCP/HostIP, GuestIP unset/ HostPort=GuestPort=3000/ doesn't work. When HostIP is changed to 127.0.0.1. It still doesn't work. No internet connection from guest and port 3000 is not shown on host machine, but can be seen on guest.
-
Eric Leung over 9 yearsNeed to see why guest can't access Internet, otherwise port forwarding never work. In guest, what IP/gateway it have ? What is the output of "ip route" ?
-
canoe over 9 years
default via 10.0.2.2 dev eth0
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15
10.0.3.0/24 dev lxcbr0 proto kernel scope link src 10.0.3.1
192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.40
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
-
Eric Leung over 9 yearsOther than normal eth0/1 interfaces it have lxc and bridge interfaces also (probably because LXC installed). Did those eth0/1 interfaces are part of the bridge ? What is the output of
brctl show
? If it is, you might need to disable to bridge iptables bysysctl –w net.bridge.bridge-nf-call-iptables=0
-
canoe over 9 yearsFrom the output it seems eth0/1 are not part of the bridge. bridge name bridge id STP enabled interfaces\n lxcbr0 8000.000000000000 no\n virbr0 8000.000000000000 yes\n I don't use LXC myself maybe it is installed by other software that needs it.
-
serup about 7 yearsthis worked for me with a ubuntu VM nested ubuntu VM on a windows - running jenkins with portforwarding 127.0.0.1 8080 --> 8080 ; first adapter was NAT and second set to Host-only Adapter vboxnet0 ; this portforwarding done in nested VM