VirtualBox Port Forwarding with Linux Host
The first of many ways to handle VirtualBox's virtualization is to Port Forward. Make sure you have the latest of VirtualBox. This allows a person to connect to the virtual machine directly through SSH or view the web server through a browser. Basically, we have the host machine (your actual computer's Operating System) and your guest machine (your virtual machine). So far, this is only for GNU/Linux host how to. Later the windows host how to will be added. Here is the Microsoft Windows how to.
In your GNU/Linux host's terminal application, run the following commands (Warning: make sure the quotes are proper quotes due to this CMS' protection from quotes Update: this quotation issue has been fixed the quotes you see should work):
VBoxManage setextradata "name of vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222
VBoxManage setextradata "name of vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata "name of vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP
Before running those commands, replace the following with your personal settings:
- Replace "name of vm" with your virtual machine
- Replace ssh with the preferred name you want. This is _required_ to be unique among the three commands.
- Replace 2222, 22, TCP respectively with your desired host port, guest port, and protocol.
I use port 2222 for the host in this example so it will not conflict on most configurations. This can be replaced with any port setup you desire:
- Apache (port 80)
- MYSQL (port 3306 [Update: requires both TCP and UDP])
- Any many more possibilities
One important note is to make sure you restart all VirtualBox applications (ie. the virtual machine, VirtualBox GUI, all of it). This allows the settings to be used properly.
Once this is done and your virtual machine is restarted, run these commands to verify:
VBoxManage getextradata "name of vm" enumerate
And/or
ssh -l user_name -p 2222 localhost
If you want to clear the virtual machine settings, run this ( Only use this command if you want to clear the settings for this! ):
VBoxManage setextradata "name of vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort"
VBoxManage setextradata "name of vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort"
VBoxManage setextradata "name of vm" "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol"
Enjoy
March 16th, 2008 at 09:39:37
[...] liegen könnte. Und so schmökerte ich ein wenig nach Port Forwarding unter Virtualbox bis ich auf diesen Artikel stieß. Hier nun der Code, der konkret benötigt wird, um unter der VM Port Forwarding zu [...]
August 17th, 2008 at 15:27:13
[...] VirtualBox Port Forwarding with Linux Host [...]
October 17th, 2008 at 15:38:22
[...] excellent article on the subject: Source. VBoxManage setextradata "name of vm" [...]
April 6th, 2009 at 05:58:14
[...] liegen könnte. Und so schmökerte ich ein wenig nach Port Forwarding unter Virtualbox bis ich auf diesen Artikel stieß. Hier nun der Code, der konkret benötigt wird, um unter der VM Port Forwarding zu [...]