I exported a VirtualBox VM (Debian 7.11) from Mac and imported it on my Linux machine (Ubuntu 17.04). Everything seems to work fine, except my imported machine can't connect to the internet.
(I guess I did not change the MAC addresses on import as that failed for some reason that I did not investigated further.)
Here's the current setup:
VirtualBox is configured to have a "NatNetwork" and a "Host-only network"
For the VM both network adapters are active and cable is connected.
On the host and inside the VM there is a OpenVPN configuration (the same on both machines). But it is not activated for now.
The guest machine
# /etc/init.d/openvpn status
[FAIL] VPN 'vpn' is not running ... failed!
# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:e7:5d:aa inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fee7:5daa/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4 errors:0 dropped:0 overruns:0 frame:0 TX packets:357 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1830 (1.7 KiB) TX bytes:21368 (20.8 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:cb:4b:40 inet addr:192.168.56.120 Bcast:192.168.56.255 Mask:255.255.255.0 inet6 addr: fe80::a00:27ff:fecb:4b40/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:3466 errors:0 dropped:0 overruns:0 frame:0 TX packets:3228 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:2247873 (2.1 MiB) TX bytes:638995 (624.0 KiB)
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:16436 Metric:1 RX packets:659 errors:0 dropped:0 overruns:0 frame:0 TX packets:659 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:49216 (48.0 KiB) TX bytes:49216 (48.0 KiB)
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.2.1 0.0.0.0 UG 0 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
# iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPTNow the test:
# ping -c 1 192.168.56.1
PING 192.168.56.1 (192.168.56.1) 56(84) bytes of data.
64 bytes from 192.168.56.1: icmp_req=1 ttl=64 time=0.831 ms
--- 192.168.56.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.831/0.831/0.831/0.000 ms
# wget 172.217.21.206 # google.com
--2017-05-25 17:31:28--
Connecting to 172.217.21.206:80... failed: No route to host.The host machine
# /etc/init.d/openvpn status
● openvpn.service - OpenVPN service Loaded: loaded (/lib/systemd/system/openvpn.service; enabled; vendor preset: enabled) Active: inactive (dead) since Thu 2017-05-25 17:33:12 CEST; 3s ago Main PID: 1280 (code=exited, status=0/SUCCESS)
# ifconfig
enp0s31f6: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 54:ee:75:c6:13:46 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 device interrupt 16 memory 0xf1200000-f1220000
enx0050b6dfa166: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.178.26 netmask 255.255.255.0 broadcast 192.168.178.255 inet6 fe80::1682:e4a2:aca4:9424 prefixlen 64 scopeid 0x20<link> ether 00:50:b6:df:a1:66 txqueuelen 1000 (Ethernet) RX packets 1310132 bytes 1599207507 (1.5 GB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 840018 bytes 90022576 (90.0 MB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 7627 bytes 379131 (379.1 KB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 7627 bytes 379131 (379.1 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.56.1 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::800:27ff:fe00:0 prefixlen 64 scopeid 0x20<link> ether 0a:00:27:00:00:00 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3557 bytes 299336 (299.3 KB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:1d:1b:76 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp4s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500 ether 06:eb:85:c3:6b:3a txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.178.1 0.0.0.0 UG 100 0 0 enx0050b6dfa166
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enx0050b6dfa166
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 vboxnet0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
192.168.178.0 0.0.0.0 255.255.255.0 U 100 0 0 enx0050b6dfa166
# iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-A INPUT -i virbr0 -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -i virbr0 -p udp -m udp --dport 67 -j ACCEPT
-A INPUT -i virbr0 -p tcp -m tcp --dport 67 -j ACCEPT
-A FORWARD -d 192.168.122.0/24 -o virbr0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -s 192.168.122.0/24 -i virbr0 -j ACCEPT
-A FORWARD -i virbr0 -o virbr0 -j ACCEPT
-A OUTPUT -o virbr0 -p udp -m udp --dport 68 -j ACCEPT
# cat /proc/sys/net/ipv4/ip_forward
1And the tests:
# ping -c1 192.168.56.120
PING 192.168.56.120 (192.168.56.120) 56(84) bytes of data.
64 bytes from 192.168.56.120: icmp_seq=1 ttl=64 time=1.66 ms
--- 192.168.56.120 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.664/1.664/1.664/0.000 ms
# wget 172.217.21.206 # google.com
--2017-05-25 17:39:15--
Connecting to 172.217.21.206:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: [following]
--2017-05-25 17:39:15--
Resolving ()... 172.217.22.196
Connecting to ()|172.217.22.196|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: [following]
--2017-05-25 17:39:15--
Resolving ()... 216.58.207.131
Connecting to ()|216.58.207.131|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’
index.html [ <=> ] 11,05K --.-KB/s in 0,003s
2017-05-25 17:39:15 (4,11 MB/s) - ‘index.html’ saved [11316]So on the host normal internet access is available and the guest machine is available via network. (I can even ssh into the VM from the host.)
What I tried additionally:
iptables -Fon the host
What am I missing? On the Mac machine it works without problems (in the same network).
Is something missing in the iptables configuration? Or should that be handled from VirtualBox itself?
22 Answers
I had the same problem after releasing and re-attaching a Linux VDI in order to make a backup. Could ping external sites from within the VB session, but not load pages. Tried multiple configs of the network adapter (NAT / Bridged).
In the end, got it to work by disabling Adapter 1 and instead enabling Adapter 2 (as Bridged), which worked fine.
TLDR: you need to change DNS settings
If you have output for cat /etc/resolv.conf something like this:
# Generated by NetworkManager
nameserver ::1Than change your dns settings: run sudo nano /etc/resolv.conf
And add text to the file:
nameserver 1.1.1.1
nameserver 1.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4