I have a CentOS 6.1 virtual machine, virtualized with VirtualBox on Windows XP. This machine hosts my local development MySQL server.

I'd like to find the correct network configuration, so that:

  • my guest machine always has the same IP, and is accessible from the host
  • my guest machine can always use the host's internet access (whether wired or wireless)

I've so far tried these different solutions:

  • NAT
    • pros: provides internet access, whichever the connection
    • cons: does not provide a working connection from the host to the guest
  • Bridge
    • pros: provides bidirectionnal network connection, provides internet connection
    • cons: works only with one adapter, I have to switch the settings each time my connection parameters change
  • Host-Only Network
    • pros: provides bidirectionnal network connection
    • cons: no internet access from the guest

Any better idea to achieve my goal?

migrated from serverfault.com Dec 18 '11 at 15:19

This question came from our site for system and network administrators.


Consider configuring the machine with two interfaces instead of one.

On the first you can use the Host-only Adapter so that your host can always talk directly to the guest. Then configure a second interface as either NAT or Bridged Adapter depending on your specific needs for your application.

If your guest is running as a server then you'll want Bridged. For the interface that is running in Bridged mode it will act just like a regular interface, so if you want a static IP address you'll either need to configure your network's DHCP server to assign the same IP address to the MAC address of your virtual Bridged interface, or you'll have to set up that Bridged interface statically (not recommended if your network uses DHCP unless you coordinate it with your local network admins... in which case you're better off asking for the same IP address from the DHCP server).

  • 1
    Excellent solution, thanks! Host-only + NAT is exactly what I was looking for. – Benjamin Jan 12 '12 at 12:42

I am also a virtual machines fanatic and I use VMware Workstation for my needs but I have also used VirtualBox as well. No matter what you use you will always have those three options to choose from.

My advice for your problem is to use the Bridged network option and to asign a static IP address on your virtual machine.
Just remember that if you use DHCP for the distribution of IP addresses you will have to add an exclusion in the DHCP pool just in case, so that the assigned IP address will not overlap with another leased address.

  • Thanks for your answer. I liked the Bridged option, until I realized that it stops working when the network cable is not plugged in; I thought that because both host & guest had static IP addresses, that would still work without an actual wire connection. Too bad. – Benjamin Dec 18 '11 at 15:01
  • 1
    Also take note that virtual box creates a virtual network adapter. In Win7 it is located in Control Panel\Network and Internet\Network Connections .. try to use that adapter to connect the host and the virtual machine when you are offline :) I remember that when I used virtualBox I have somehow via that network adapter connected my virtual machine and my host so that i can transfer files between them. (this may be a little of topic but I am telling you this to compare it to your situation.) – Spirit Dec 18 '11 at 15:25
  • That's exactly what I did so far, but I hoped that maybe a better solution existed, hence my question :) – Benjamin Dec 18 '11 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.