6

In Virtualbox version 4.3.26 I would like to install Ubuntu 16.04 client. The network configuration is adapter 1 : bridged adapter name : eth0 adapter 2 : NAT

With this configuration I do have internet access, but not to my local network.

I tried : static-ip-in-virtualbox-machine-with-ubuntu-16-04 but when setting to host-only, I was not able to select any thing.

I have read Virtualbox manual chapter 6 but could not find a solution.

I have tried how to rename a network card but adding a rule did not work for me.

In my other virtualbox clients I had to add in the client (Ubuntu) interfaces file (/etc/network/interfaces) with the result :

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth1
iface eth1 inet static
dns-nameservers 192.168.1.70 192.168.1.1
address 192.168.1.66
gateway 192.168.1.1

And in the virtualbox network setting adapter 1 : bridged adapter, name : eth0

With this configuration I have access to my local network and Internet with my other (Ubuntu 14.04) Virtualbox clients.

The name system in Ubuntu 16.04 has altered, no eth0 anymore but by checking using ifconfig :

me@vBox1b-client:~$ ifconfig
enp0s3    Link encap:Ethernet  HWaddr 08:00:27:9e:aa:c9  
          inet addr:192.168.1.78  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe9e:aac9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:41 errors:0 dropped:0 overruns:0 frame:0
          TX packets:84 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4304 (4.3 KB)  TX bytes:8988 (8.9 KB)

enp0s8    Link encap:Ethernet  HWaddr 08:00:27:17:a7:e6  
          inet addr:10.0.3.15  Bcast:10.0.3.255  Mask:255.255.255.0
          inet6 addr: fe80::a16b:7a82:bf0b:7247/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:67 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1328 (1.3 KB)  TX bytes:7953 (7.9 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:10 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1 
          RX bytes:534 (534.0 B)  TX bytes:534 (534.0 B)

So with this info I changed my interfaces file into :

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
dns-nameservers 192.168.1.70 192.168.1.1
address 192.168.1.66
gateway 192.168.1.1

I rebooted and indeed I had access to my local network, but not to Internet anymore.

So in Virtualbox server I wanted to changed in adapter 1 with name : eth0 to enp0s3 but I could not change the name at all.

The DNS seems to be ok.

Local :

ping mylocal.com
PING mylocal.com (192.168.1.73) 56(84) bytes of data.
64 bytes from 192.168.1.73: icmp_seq=1 ttl=64 time=0.961 ms

The DNS can find the local IP address and the IP address does response.

Internet (glocal):

ping nu.nl
PING nu.nl (62.69.166.254) 56(84) bytes of data.
From 192.168.1.66 icmp_seq=1 Destination Host Unreachable

Also global the DNS can find the IP address, but the IP address does not response.

The DNS server which is used :

nslookup host
Server:     192.168.1.70
Address:    192.168.1.70#53

There might be a conflict with Virtualbox MAC addresses, so I refreshed them, in Virtualbox manager, but without result.

I have three question :

  1. How it is possible that adding a network blocks Internet access? I would really like to comprehend what is happening, this makes understand a solution better.
  2. Why Virtualbox does not let me alter the adapter name into enp0s3?
  3. How can I have access to Internet and my local network together?
10

When you add a new network adapter and set a gateway, it becomes "default gateway" and all Internet traffic is redirected through it, in your case gateway 192.168.1.1.

Try to remove/comment gateway 192.168.1.1 in your network settings. I also use two network adapters.

First one is "NAT" type and is for Internet access and is set to dhcp. Second in "Host-only" for connection between virtual machines and is static IP. Don't set gateway to it, because it's only for connection between the VMs.

You also need to add "Host-only" adapter form File → Preferences → Networks → Host only Networks.

Here you can find detailed explanation http://www.slideshare.net/powerhan96/networking-between-host-and-guest-v-ms-in-virtual-box, and here is my /etc/network/interfaces

# The Loopback network interface
auto lo
iface lo inet loopback

#The Primary network interface
auto enp0s3
iface enp0s3 inet dhcp

#The secondary network interface (host-only)
auto enp0s8
iface enp0s8 inet static
    address 192.168.56.101
    network 192.168.56.0
    netmask 255.255.255.0
    broadcast 192.168.56.255
    #gateway 192.168.56.1 NOTE: remove/comment gateway or set enp0s3 as a default gateway. 
  • I comment the gateway out in the interfaces file and now I do have access to internet AND my local network. Bravo! Thanks. I tried to set Virtualbox to host-only but the only selection possible is "Not selected". But I do not mind, I appreciate your answer very much. – Bernard May 27 '16 at 19:15
  • This is the best explanation online to solve this problem. Thanks – Nick Pyett Nov 21 '16 at 17:07
  • Thanks so much for the solution! I got the same problem and also tried so many tutorials, but none of them works!!! At last, I got this solution, it works!!! I almost crying!!! – xirururu Dec 6 '16 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.