user994165
user994165

Reputation: 9502

Ubuntu: Can't connect to host's internet connection using NAT

I installed Lubuntu on Virtualbox. I'm using Windows 7 x64. My VM is 32 bit version. The internet works using Bridged Adapter, but I'm trying to use NAT so I can use a VPN. In Network and Sharing Center in Windows, I see connection "VirtualBox Host-Only Connection" and it says "No Internet Access". In properties, "VirtualBox Bridged Networking Driver" is checked. The following is the output of ifconfig:

dev@dev-VirtualBox:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:f3:48:24  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fef3:4824/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:379 errors:0 dropped:0 overruns:0 frame:0
          TX packets:421 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:32105 (32.1 KB)  TX bytes:34987 (34.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:856 errors:0 dropped:0 overruns:0 frame:0
          TX packets:856 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:56432 (56.4 KB)  TX bytes:56432 (56.4 KB)

Routing Table:

dev@dev-VirtualBox:~$ route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        *               255.255.255.0   U     1      0        0 eth0
dev@dev-VirtualBox:~$ 

Connection Editor: General: Automatically Connect to this network when it isn't available, All users may connect ot this network Ethernet: MTU automatic IPV4: Automatic (DHCP), Require ipv4 addressing for this connection to complete IPV6: Ignore

dev@dev-VirtualBox:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

Upvotes: 6

Views: 15784

Answers (3)

Dorcioman
Dorcioman

Reputation: 636

To troubleshoot this, you can try the following.

Check VirtualBox Configuration

Open VirtualBox Manager -> Open Machine Setting -> Select "Network":

  • Enable Netowrk Adapter: check
  • Attached to: NAT
  • Cable Connected: check

Check the status of your interfaces

ip address show

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 08:00:27:c7:e3:b9 brd ff:ff:ff:ff:ff:ff inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic enp0s3 valid_lft 81707sec preferred_lft 81707sec inet6 fe80::a00:27ff:fec7:e3b9/64 scope link valid_lft forever preferred_lft forever

3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default link/ether 02:42:b1:8f:dd:00 brd ff:ff:ff:ff:ff:ff inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0 valid_lft forever preferred_lft forever

In this step you may want to check two things: if the interface is up and if you have an IP address assigned.

Enable the Network Interface

sudo ip link set enp0s3 up

Request new IP address from DHCP

sudo dhclient -r enp0s3
sudo dhclient enp0s3

Upvotes: 2

user12182610
user12182610

Reputation:

Just type this command:

sudo dpkg-reconfigure resolvconf

Upvotes: 0

user994165
user994165

Reputation: 9502

It turns out that NetworkManager was not updating /etc/resolv.conf with the nameservers.

Commenting out dns=dnsmasq in /etc/NetworkManager/NetworkManager.conf worked after rebooting.

From here (the first solution didn't work for me) https://askubuntu.com/questions/137037/networkmanager-not-populating-resolv-conf

Upvotes: 6

Related Questions