The default way a VirtualBox machine connects to the network is using NAT. Since it’s connected to a private network, you can connect to the outside world but other machines cannot contact you (this holds true even for the host machine). NAT is the easiest and most lightweight way of connecting your virtual machine to the network. VirtualBox also supports others ways of connecting to the network such as a bridge adaptor.
My current setup: I have one virtual machine running Ubuntu 9.04 where I have all my development tools and languages installed (ruby, php, python etc). I run VirtualBox 3.0.8 on my MacOS laptop. This way I can be as close to the server environment as possible while building my applications. I run Apache, Passenger, PHP, MySQL on the guest machine and just forward 22 (ssh), 80 (http) and 3306 (mysql) to MacOS this way I can use apps like MySQL workbench to play with my database or Textmate to code.
The easiest way to get access the guest machine is by using “port forwarding”.
VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/Protocol' TCP VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/GuestPort' 80 VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/Apache/HostPort' 8080
Similarly I setup a couple more to make my development easier
VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/MySQL/Protocol' TCP VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/MySQL/GuestPort' 3306 VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/MySQL/HostPort' 3306
This one will map Mysql Server
VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/Protocol' TCP VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/GuestPort' 22 VBoxManage setextradata 'Ubuntu Development' 'VBoxInternal/Devices/pcnet/0/LUN#0/Config/SSH/HostPort' 2222
And this SSH.
NAT Limitations
Comments
Post new comment