# Question on Virtualbox and network issues



## Αbominable (Nov 20, 2014)

Dear all,

I am completely new to BSD so sorry in advance for stupid questions.

I installed FreeBSD 10.0-RELEASE to experiment with FreeBSD.  I wanted to create some virtual machines for further testing. So I installed Virtualbox and created a number of virtual machines (CentOS 6.6)

My main problem was the networking. So after digging a bit I decided to create two network interfaces on each machine. One (Host only) for Host-Guest and Guest-Guest communication and one (NAT) for internet access.

The first one was set with specific IPs so I can SSH and it worked without any issue.

The second one was set with DHCP and each VM/eth_interface got an IP in the range 10.0.2.* .

Because I could not access the internet, I checked the route and saw that there was no route to the 10.0.2.* network. So I disabled the 1 first interface (from the VM settings) and left only the second one. I booted again the VM. The eth_interface got the IP in the 10.0.2.* range and route had as default gateway the 10.0.2.2 (which I presume is the Host's IP?). I can ping 10.0.2.2 but I cannot ping 8.8.8.8, www.google.com, or any known internet IP/site.

The funny thing is that on half of the VMs I managed to "yum install packages" the other half couldn't resolve the nameservers of CentOS mirrors.

If you have any possible idea on what to check for discovering the problem, I would gladly welcome it.


----------



## justwantask (Nov 20, 2014)

Hi,

Try enabling forwarding 
	
	



```
sysctl net.inet.ip.forwarding=1
```
 or in /etc/rc.conf:

```
gateway_enable="YES"
```


----------



## wblock@ (Nov 20, 2014)

VirtualBox acts as a DHCP server and gateway for VMs in NAT mode.  That's where the 10.0.2.2 comes from.

I have not had a problem with a default route on a VirtualBox NAT VM that I can recall.  It has always just worked.


----------



## wblock@ (Nov 20, 2014)

justwantask said:


> Hi,
> try enable forwarding
> 
> 
> ...



This is not needed for VirtualBox NAT or bridged VMs.


----------



## drhowarddrfine (Nov 20, 2014)

These are notes to myself for FreeBSD 9 a while back. Whether they apply to FreeBSD10 or CentOS still, I do not know.



> To get Centos to run on Virtual Box, in /etc/sysconfig/network-scripts/ifcfg-eth0:
> 
> DEVICE=eth0
> BOOTPROTO=dhcp
> ...


----------



## derwood (Nov 21, 2014)

In Virtualbox did you set the interfaces to bridged? I believe they're not set to that by default when you add it to the VM.
I also make sure the interface is set to e1000 to ensure compatibility.


----------



## wblock@ (Nov 21, 2014)

Bridged interfaces are only required if the VM is to be connected directly to the host's network.  VirtualBox can actually port-forward to VMs using NAT.

Oh, and vboxnetadp.ko and vboxnetflt.ko must be loaded to use bridged networking.  /usr/local/etc/rc.d/vboxnet does that.  NAT does not require these modules.


----------

