Problem
In a VirtualBox guest machine I wanted to set up a web server for testing purposes. How to access the guest’s web server from the host?
Solution
In the guest’s network settings, normally you already have a NAT network adapter. This way the guest can access the Internet.
But how to establish a network communication between the host and the guest? In the guest’s network settings, select the tab “Adapter 2”. At home “Bridged Adapter” worked for me.
However, at my workplace “Bridged Adapter” didn’t work. After some research I wanted to try “Host-only Adapter”, but I ran into a difficulty. I couldn’t add a host-only adapter, I got the following error message: “no host-only network adapter selected”. And the GUI didn’t offer anything in the dropdown list :(
Fortunately I found the solution here. The image above was also borrowed from askubuntu.com.
For future references, I quote the steps here:
“Probably, the virtual host-only network wasn’t set up yet. Here’s is how you can fix this:
- From the main menu, select File > Preferences (Ctrl+G) – NOT the settings of a single vm
- Select Network in the list on the left
- You should see an empty white box with “Host-only Networks” at the top. On the right, there are three buttons to manage them. Click the topmost one (with a green plus symbol). A new Host-only network will be created and added to the list.
Normally, the settings of the new network will be ok, but for completeness, I give the default values here. You can access the settings for the host-only network through the screwdriver button on the right.
- Adapter:
- IPv4 address: 192.168.56.1
- IPv4 Network Mask: 255.255.255.0
- DHCP server:
- Enable server: checked
- Server Address: 192.168.56.100
- Server Mask: 255.255.255.0
- Lower Address Bound: 192.168.56.101
- Upper Address Bound: 192.168.56.254
You can change these settings to your liking, as long as they’re consistent.”
Thanks to Bert Van Vreckem for this great answer.
Guest’s IP address
Executing “ifconfig
” in the guest, you’ll get its IP address. Mine is under “eth1”, next to “inet addr:”. Try to ping the guest from the host and vice versa. They should work :)
You must be logged in to post a comment.