I was wondering if someone could give me a simple guide on how to set up virtual networking in VirtualBox (4.0.2) so that the following scenarios work:

  • Both Host and Guest can access the Internet
  • Host can ping Guest and vice versa
  • Host can access, for example, an apache web server running on Guest and vice versa

I've been fiddling around with the various Network Adapters available in the settings for my Guest, but I'm just not able to figure it out. Is there anyone that can help me out here?

The host is running Windows 7 32-bit and the guest is running Ubuntu 10.10 32-bit.

  • 111
  • 1
  • 9
  • 6,977
  • 15
  • 38
  • 45
  • I have the same setup set up with bridged networking. I had problems using the paravirtualsed network adaptor virtio-net, it was very flaky. The emulated nics were fine though. – ollybee Apr 06 '11 at 20:34
  • 1
    I was tearing my hair out on this, I was already using Bridge Mode. What I needed to change was the name of the bridged adapter - it was my Wifi network. When I changed it to my LAN it magically started working. No restart of the VM necessary. – Sridhar Sarnobat Nov 15 '18 at 22:15

6 Answers6


Try this:

  1. Setup the virtualbox to use 2 adapters:
    • The first adapter is set to NAT (that will give you the internet connection).
    • The second adapter is set to host only.
  2. Start the virtual machine and assign a static IP for the second adapter in Ubuntu (for instance The host Windows will have as IP for the internal network (VirtualBox Host-Only Network is the name in network connections in Windows). What this will give you is being able to access the apache server on ubuntu, from windows, by going to Also, Ubuntu will have internet access, since the first adapter (set to NAT) will take care of that.
  3. Now, to make the connection available both ways (accessing the windows host from the ubuntu guest) there's still one more step to be performed. Windows will automatically add the virtualbox host-only network to the list of public networks and that cannot be changed. This entails that the firewall will prevent proper access.
  4. To overcome this and not make any security breaches in your setup:
    • go to the windows firewall section, in control panel,
    • click on advanced settings. In the page that pops up,
    • click on inbound rules (left column), then on new rule (right column). Chose custom rule, set the rule to allow all programs, and any protocol. For the scope, add in the first box (local IP addresses), and in the second box (remote IP) Click next, select allow the connection, next, check all profiles, next, give it a name and save.

That's it, now you have 2 way communication, with apache/any other service available as well as internet. The final step is to setup a share. Do not use the shared folders feature in virtualbox, it's quite buggy especially with windows 7 (and 64 bit). Instead use samba shares - fast and efficient.

Follow this link for how to set that up: https://wiki.ubuntu.com/MountWindowsSharesPermanently

  • 103
  • 1
  • 4
Bogdan Nicolau
  • 1,996
  • 1
  • 12
  • 3
  • 3
    This worked perfectly. Thanks. Did not have to touch firewall etc. Still having problem with bridge. – FractalSpace Oct 12 '13 at 02:17
  • 1
    This also works for VirtualBox 5.0 / Windows 10 – Jess Aug 26 '15 at 04:48
  • I had to connect to a WIndows Server 2012 VM, and had to set inbound rules on both firewalls. Now it all works perfectly :) – Alan Fluka Oct 06 '15 at 09:39
  • doesn't work with mac os guest – fire in the hole Jun 05 '17 at 07:24
  • But I am not able to connect to internet on guest machine(Mac OS X El Capitan) – Mansuu.... Jun 21 '17 at 07:24
  • virtualbox complains that the adapter has no name and there is no way to select name. The answer of The time has come works for me. – Martin Kunev Dec 12 '17 at 00:30
  • This doesn't work with Mac Host and Ubuntu guest. – weberc2 May 06 '18 at 17:05
  • Implemented this to Mac host and Win 10 guest. No need to type any other IP than the given – marlo Jun 17 '18 at 05:02
  • No way to use 2 adapters, the tab of the second adapter is gray. – inf3rno Jun 22 '18 at 00:51
  • @inf3rno have you powered off your VM before attempting to enable the second adapter? – ifo20 Feb 14 '19 at 21:47
  • how specifically do you "assign a static IP for the second adapter in Ubuntu (for instance"? – ifo20 Feb 14 '19 at 21:53
  • @ifo20 I am not sure, it was 8 months ago... – inf3rno Feb 14 '19 at 21:58
  • @ifo20: there are many ways, depending on if you have a GUI (X Server) or not. I personally don't, on my guest OS, so I set up a static ip by adding a new block down `/etc/network/interfaces` (you'll find examples easily). A couple of important points: on debian buster, netmask wasn't accepted, I had to use CIDR notation on network. Also, I had to add `gateway` (= my host's IP for VBox), run `route add default gw`, then `route del default gw` to still access the internet from my guest OS (destination =, check your routing table with `netstat -rn`. – Fabien Haddadi Dec 29 '19 at 16:02
  • "No network adapter is currently selected" error. – AgentFire Jan 13 '20 at 12:48
  • @Bogdan I did exactly as you mentioned but still only the ping is working fine vice versa. But my application is not working. I am trying to send some command from my Linux Vm to my Windows host. – Raaj Lokanathan Oct 02 '20 at 01:51
  • 1
    Only had to do steps 1 and 2 on OSX El Capitan host and Ubuntu 20.04.1 guest. However, to set up the Host only adapter, I had to follow this first https://askubuntu.com/questions/198452/no-host-only-adapter-selected – RisingSun Dec 09 '20 at 15:34
  • Worked beautifully. I did need to do the firewall step on Windows 10. – KateYoak Aug 04 '21 at 19:19
  • My network adapter in Alma Linux 8.8 accepted this manual configuration only after I restart the machine. Before that, the adapter stuck at the address or (beginning of DHCP range of VirtualBox). – aldemarcalazans Jul 14 '23 at 04:47

The best way to do this is to use a Bridge Adapter in virtualbox. In virtual box go to the settings for your machine->Network->Adapter 1 and select Bridged Adapter. This will make you virtual machine part of your main network.

If you have a dhcp server it should supply an address etc. to the virtual machine which will allow it to communicate with the rest of your systems and vice versa.

  • 115,471
  • 20
  • 215
  • 297
  • When I did this I was not able to ping the Host from the Guest. Should I be able to do this? Is it something in my Host blocking the ping perhaps? – Svish Jan 21 '11 at 14:44
  • 1
    You may have to allow ping through your windows firewall have a look [here](http://social.answers.microsoft.com/Forums/en-US/w7network/thread/5aff5f8d-f138-4c9a-8646-5b3a99f1cae6) for how to do that. – user9517 Jan 21 '11 at 15:27
  • If you still have problems pinging the machines from one another make sure that the Bridged adapter is connected to the correct NIC card of the Host machine. For some reason sometimes VirtualBox attaches the Bridged Adapter to the wrong, or to a non-existent Network Card on the Host. – isapir Aug 21 '16 at 22:54
  • @Hanginoninquietdesperation the link you provided on how to pass the firewall is dead – Francesco Dondi Nov 23 '16 at 14:35
  • 2
    worked for me (mac os guest) – fire in the hole Jun 05 '17 at 07:24
  • Does not work here, it loses internet connection I have with NAT. My problem with NAT, that my requests to the host OS servers use to timeout except HTTP. I tried samba and ftp (even in passive mode), but none of them worked. – inf3rno Jun 22 '18 at 00:53
  • This works on Debian 10 (host) and Centos 8 (guest). – 71GA Jan 23 '20 at 09:35
  • 2
    Bridged network seems to work fine if you are connected through ethernet. Does not seem to work when the host is connected through wifi – RisingSun Dec 09 '20 at 15:36
  • Bridged network download throughput is about 300 B/s on my Wi-Fi adapter. – weeix Apr 23 '22 at 11:41

Just after the installation of VirtualBox, the next step is to go to the Preferences of VirtualBox (inside File menu:Ctrl+G) and select Network.

VirtualBox Preferences, Network tab. The Network tab is listed after General, Input, Language, and Display, and is followed by Extensions and Proxy.

Then add a New Nat Network.

A new, active NAT Network.

Given the requirements, I would choose a "bridged" adapter.

Within the network settings, on the "Adapter 1" tab. "Enable Network Adapter" is ticked, and "Attached to:" is selected to "Bridged Adapter".

  • 107
  • 1
  • 5
  • 189
  • 4

ON virtualbox 5.2, it's real easy: Set up a bridged adapter for the guest.

When you start the guest, it will use the same network as the host, using DHCP to get its own IP address.

O. Jones
  • 233
  • 3
  • 6

Setup host-only network and allow sharing of internet connection for that network. In this way you will have virtual interface on host that will be connected to guest.

  • 2,341
  • 20
  • 19
  • How would I do this? I tried to use host-only network for the guest, but then it seems to use ipv6 and I couldn't ping in either direction as far as I could understand... – Svish Jan 21 '11 at 14:03
  • You can manually setup IPv4 addresses on both ends. – gelraen Jan 21 '11 at 14:13
  • Static IP you mean? There's no way of having the guests get their IP from DHCP? Or will they be like behind a NAT? Also, what do you mean by "allow sharing of internet connection for that network"? How can I do that? – Svish Jan 21 '11 at 14:17
  • Yes, static IP. It is better to have IP statically assigned if you want communicate with guest. With host-only guest will be directly visible from host. Internet connection sharing in windows® configured on last tab in properties of your internet connection. – gelraen Jan 21 '11 at 17:48

According to the Virtualbox documentation ch 6.2 and its helpful table, Bridged Adapter seems to be the most permissive.

However, I have found that sometimes no settings through virtualbox have any effect whatsoever, and when that has been the case, I've solved this directly in the Linux guest via the command line.

  1. Change Virtualbox settings to bridged and use VB's recommended settings.
  2. In the Linux guest, via the command line as root / sudo, run nmtui which will bring up a user interface. Of the 3 options select "Activate a connection" and choose the name of the network adapter that VB assigned to the guest. If your host is permissive enough, this should set everything up. If not, you may need to select "Edit a connection" instead to manually input DNS servers, IP addresses, DHCP vs Static, gateway, etc. Don't forget to select "Automatically connect" in the edit screen.

When all else has failed, this has always been the answer for me.

  • 135
  • 7