Accesing internet with Host-Only network VirtualBox

7,310

Solution 1

Make sure the second network adapter is enabled. Also check the Advanced section for the second network adapter (Attached to: NAT) to make sure it's the same Adapter Type as the first network adapter (not a requirement but this way you will know the driver is loaded for it) and that Cable Connected is checked.

Verify in the FreeBSD guest that the /etc/rc.conf file has an entry to enable the added adapter. You'll see a line such as:

ifconfig_dc0="DHCP"

for the first and make sure there's an entry for the added adapter as well, example:

ifconfig_dc1="DHCP"

(replace the dc before the 1 with the same thing the current line has before the 0) then reboot the guest OS.

Solution 2

Adding a network card is quite easy.

In the Networking section of the Virtual Machine's settings, choose an adapter tab. Tick Enable Network Adapter. For internet access, a NAT adapter is the easiest option. Then just click OK and you should be good to go!

Screenshot
Click for full size


See the VirtualBox networking documentation for detailed descriptions of what each adapter does.

Note that the GUI for VirtualBox only supports four adapters. To add more, you can use the VBoxManage modifyvm command (modifyvm networking documentation). VBoxManage list systemproperties will show the max number of network adapters available:

Maximum PIIX3 Network Adapter count:   8
Maximum ICH9 Network Adapter count:   36

PIIX3 and ICH9 are the two chipset options available on VirtualBox. PIIX3 is a very old chipset (and therefore does not support as many peripherals), but is the default for new VMs. You can change this in the System settings of the VM.

Share:
7,310
Bibo
Author by

Bibo

Updated on September 18, 2022

Comments

  • Bibo
    Bibo over 1 year

    I have two VMs in my VirtualBox. Both are FreeBSD and should communicate between each other. I have created network with DHCP enabled and set like this:

    Server Address  10.10.10.1
    Server Mask 255.255.255.0
    Lower Address Bound 10.10.10.100
    Upper Address Bound 10.10.10.200
    

    My VMs are pinging each other and getting right ip adress. This is what I must have and can´t change.

    Now I want to access internet from one VM and I found that I must use two network cards but I don´t know how to set the second one. I am new with VirtualBox and this stuff so if you count with this in you answer I would appreciate that. And I have Windows 8 as host system if it´s matter.

    • harrymc
      harrymc over 11 years
      Why not define the network adapter as NAT for all VMs and let your router handle the DHCP?
    • Bibo
      Bibo over 11 years
      I have it like that because I need it for school project.
  • Bibo
    Bibo over 11 years
    This is what I tried when I found that I must use two cards. Just added second card with NAT adapter but it didn´t help. I don´t know if it is because for Host-only I get dynamic ip from dhcp or something else. I just must set more settings for internet.
  • tvdo
    tvdo over 11 years
    @Bibo Anything else is probably a configuration issue on the guest side. Make sure the guest can see the adapter (ifconfig), and take a look at the FreeBSD documentation on adding a network adapter. Win7/Kubuntu/OpenSUSE guests always detected the adapter automatically for me, but I've never used FreeBSD before.
  • harrymc
    harrymc over 11 years
    Putting the NAT adapter first may help.
  • Bibo
    Bibo over 11 years
    This was exactly what I was looking for. I knew that I must set something it settings and that It can´t be hard. Thank you very much.