# Could not get  NAT  to work with VirtualBox



## demonking (Jun 19, 2015)

Hello,

iI hope that iI'm right here.

I tried to get NAT working with VirtualBox, but somehow I'm missing something.

For testing iI have installed a Virtual Machine with Debian Jessie x86.
But the main problem is, that iI cannot access the net in the VM.

My information:

`/usr/ports/emulators/virtualbox-ose && make showconfig`:

```
===> The following configuration options are available for virtualbox-ose-4.3.28:
  DBUS=on: D-Bus IPC system support
  DEBUG=off: Debug symbols, additional logs and assertions
  GUESTADDITIONS=on: Build with Guest Additions
  MANUAL=off: Build with user manual
  NLS=off: Native Language Support
  PULSEAUDIO=off: PulseAudio sound server support
  PYTHON=on: Python bindings or support
  QT4=off: Build with QT4 Frontend
  UDPTUNNEL=on: Build with UDP tunnel support
  VDE=off: Build with VDE support
  VNC=on: Build with VNC support
  VPX=off: Use vpx for video capturing
  WEBSERVICE=on: Build Webservice
  X11=on: X11 (graphics) support
===> Use 'make config' to modify these settings
```
`cat /etc/rc.conf`

```
hostname="myhostname"
zfs_enable="YES"
keymap="de.acc.kbd"
sshd_enable="YES"
openntpd_enable="YES"
openntpd_flags="-sv"
fusefs_enable="YES"

#nginx and fpm
nginx_enable="YES"
php_fpm_enable="YES"


wpa_supplicant_enable="YES"

dumpdev="AUTO"

#networksettings
ifconfig_re0="up"
MAC=`ifconfig re0 | grep ether | awk '{print $2}'`
ifconfig_ath0="ether $MAC"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto failover laggport re0 laggport wlan0 SYNCDHCP"

#mouse+snaptics

moused_enable="YES"
moused_flags="-F 200 -A 1.2 -a 1.2 -r high"

#printer
lpd_enable="NO"
cupsd_enable="YES"

#sound
mixer_enable="YES"

#webcam
webcamd_enable="YES"

#firewall
pf_enable="YES"
pflog_enable="YES"

#virtualbox
vboxnet_enable="YES"

# Asynchronous I/O
aio_load="YES"

#clear tmp on restart
clear_tmp_enable="YES"

# Gateway
gateway_enable=”YES”
```
Virtualbox Settings:

```
NIC 1:  MAC: 0800274182B3, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
```
`netstat -rn`

```
Routing tables

Internet:
Destination  Gateway  Flags  Netif Expire
default  192.168.2.1  UGS  lagg0
127.0.0.1  link#3  UH  lo0
192.168.2.0/24  link#4  U  lagg0
192.168.2.34  link#4  UHS  lo0

Internet6:
Destination  Gateway  Flags  Netif Expire
::/96  ::1  UGRS  lo0
::1  link#3  UH  lo0
::ffff:0.0.0.0/96  ::1  UGRS  lo0
fe80::/10  ::1  UGRS  lo0
fe80::%lo0/64  link#3  U  lo0
fe80::1%lo0  link#3  UHS  lo0
ff01::%lo0/32  ::1  U  lo0
ff02::/16  ::1  UGRS  lo0
ff02::%lo0/32  ::1  U  lo0
```

iIn my VM iI get the following information:

ip:10.0.2.15
gw:10.0.2.2
bc:10.0.2.255

What could be the problem?
On my Gentoo (Linux) machine it works without problems.


----------



## wblock@ (Jun 19, 2015)

That is a strange network setup.  DHCP is run on wlan0 and then again on lagg0, lagg0 cloned, games played with the MAC address, a firewall, gateway.  It's also not clear exactly what happens on the VM.


----------



## demonking (Jun 26, 2015)

I have remove the lagg0 , firewall and the gateway but no change.


----------

