lunes, septiembre 19, 2011

VirtualBox port forwarding from HOST to GUEST

Accesing a virtualbox virtual machine's network services from the host operating system

When running a VirtualBox VirtualMachine(VM), the networking inside the VM by default is in a private network in NAT, generaly 10.0.2.x, so the GUEST can access the HOST network services, but the HOST and the outside world is unable to reach the GUEST network services.

According to the VirtualBox Manual, there are different modes of network emulation, by default the NAT mode.

A way to map (forward) a HOST port to a GUEST port exists and is posible to configure from the command line (the VM should not be running):

$ VBoxManage modifyvm windows-server --natpf1 "iis,tcp,,8080,,80"

In this case:
windows-server is the name of the VM
iis is the name of the rule
tcp the protocol, could be udp also
the host IP is left blank
the hostport is 8080
the guest IP is left blank
the guestport is 80

The restriction with this approach is that all the inbound traffic is reverse NATed so the GUEST VM will see the origin IP as 10.0.2.2.

No hay comentarios.: