Ubuntu – No Internet Access on VMs in NAT Network in VirtualBox

nat;virtualboxvirtualbox-networking

I have created a a NAT Network in VirtulBox 5 In Ubuntu 14.04 LTS with following settings

Natework Name : NatNetwrok1
Network CIDR: 10.0.2.0/24
Support DHCP :enabled
Support IPv6 :disabled
without any port forwarding

Additionally I have two VMs (Both Xubuntu clones), I have set the Network settings to enable two NICs on each of the VM with following settings in all four adapters:

Attached To : “NAT Network”

Name : “NatNetwrok1”

When I run both VMs I can see following settings on running ifconfig command

ifconfig results on Xubuntu1

eth0      Link encap:Ethernet  HWaddr 08:00:27:00:8c:03  
          inet addr:10.0.2.9  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe00:8c03/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12133 (12.1 KB)  TX bytes:8517 (8.5 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:9e:20:e8  
          inet addr:10.0.2.8  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe9e:20e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10294 (10.2 KB)  TX bytes:8798 (8.7 KB)

ifconfig results on Xubutracentu2

eth0      Link encap:Ethernet  HWaddr 08:00:27:00:8c:03  
          inet addr:10.0.2.9  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe00:8c03/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12133 (12.1 KB)  TX bytes:8517 (8.5 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:9e:20:e8  
          inet addr:10.0.2.8  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe9e:20e8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:43 errors:0 dropped:0 overruns:0 frame:0
          TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10294 (10.2 KB)  TX bytes:8798 (8.7 KB)

Ping between these 4 IPs works fine
But I can not access Internet on either of these VMs
While if o change “NAT Network” to “NAT” I can access the network but it seems the become part of different virtual network and I can not ping them from each other
Can anybody help me in identifying and fixing problem

Can anyone also explain whats difference between NAT and NAT Network

Best Answer

According to VirtualBox manual, these are the network possibilities for your VMs:

  • NAT: Internal network between VM and host. Besides you can access to the Internet. Two or more VMs in NAT mode don't have connectivity among them, only with the host and Internet.

  • Internal: All VMs with this configuration will have connectivity among them but not with the host nor Internet.

  • Host only: A virtual network will be created between the host and all the VMs with this configuration, but you will have no Internet access.

  • NAT Network: You can reach all VMs in the same pre-defined NAT network and the host, but you won't be able to connect to Internet.

  • Bridged: Your VM will be in the same network that your host as if it were other computer/server in this network, and thus, it will have Internet acces if your host has.

  • Generic: Advanced and more specific configuration rarely used.

So, if you want to create an internal network with connectivity to the host choose NAT Network, but notice that you will have no Internet access. NAT is set only when you just want Internet access from your VM and nothing else.

However none of these settings are ok with you if you want to have either connectivity between both VMs and the Internet. As far as I know, your only choice is to configure both VMs in bridged mode, so they will be 'different' computers in you host network and you will be able to ping them all and the Internet from any of them.

On the other hand, it seems that you clonned one VM from the other because both machines have the same MAC address (HWaddr in ifconfig command info), be aware that you should check the checkbox that reads "Reinitialize the MAC address of all network cards" when clonning. Two devices with the same MAC address always creates problems.

I am not an expert in VirtualBox so maybe other users can tell you other posible configurations to get what you want. I hope you find this information useful.

For more information you can read this.