Monday, November 24, 2008

VirtualBox 3: Redoing Everything

Updated to Use the Loopback Adapter and 192.168.5.1 (host), 192.168.5.2 (guest).

Well, it turns out that NAT port-forwarding was totally unecessary for what I was trying to do (although it is interesting). The answer is to use the host networking (with the loopback interface).

I don't have time to write a real blog entry, so here are my notes on it
  1. Install the server, including SSH and LAMP.
  2. Install a loopback adapter on the host
  3. Install a second network interface with "host" networking using VirtualBox, tied to the loopback adapter.
  4. Change the TCP settings for the host networking interface on the host computer to be 192.168.5.1 netmask 255.255.255.0
  5. On the guest machine, run
    sudo nano /etc/network/interfaces
  6. add these lines
    auto eth1 iface eth1 inet static address 192.168.5.2 netmask 255.255.255.0
  7. restart networking
    sudo /etc/init.d/networking restart
  8. Now you should be able to access everything including SSH from the host. Just connect to 192.168.5.2, port 22.
  9. Now, getting MySql to work. Change the /etc/mysql/my.cnf
    bind-address = 192.168.5.2
    which used to be localhost
  10. from the MySql client (you must be root!)
    grant all privileges on *.* to 'root'@'192.168.5.1';
  11. Restart MySql: sudo /etc/init.d/mysql restart
  12. Now you can connect with MySql from your host using the command-line thinger or the MySql Query whatsamagig
The stuff on the Virtual Hosts is still right (although you have to use names like blah.vbox on your Windows hosts file). In addition, the stuff I wrote about mounting volumes is still worthwhile as well. Check the two prior posts.

1 comment:

Dan Rosenstark said...

For VBox 2.10, it's different. Check out the changes here

http://compileyouidontevenknowyou.blogspot.com/2008/12/virtual-box-210-virtual-host-adapter.html