Page 1 of 1

Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 23. Aug 2015, 00:14
by kuanghongkai
Virtualbox: 4.3.30
Host OS: Windows 8.1
Guest OS: Ubuntu 14.04
Mode: NAT

========================================================================
Problem: Connect on the host is perfect. In the guest os, I can ping the host, gateway, DNS IP, and public IP like google's, no packets lost. But I can't connect to the interner at all.
1.Connection to websites using a domain name: server not found
2.Connection to websites using an IP address: server not found
3.Other way to connect like app-get and system updates doesn't work either
4.able to ping DNS but no able to resolve any domain names:

sk@sk-VirtualBox:~$ dig
; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>>
;; global options: +cmd
;; connection timed out; no servers could be reached

========================================================================
And here are some of the information of configuration of the guest:

sk@sk-VirtualBox:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:e4:a5:db
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee4:a5db/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:27 errors:0 dropped:0 overruns:0 frame:0
TX packets:1891 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3796 (3.7 KB) TX bytes:165196 (165.1 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:601 errors:0 dropped:0 overruns:0 frame:0
TX packets:601 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:41854 (41.8 KB) TX bytes:41854 (41.8 KB)

sk@sk-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

Connection configuraion:
Wired connection 1 (default)
IPv4
IP Address: 10.0.2.15
Subnet Mask: 255.255.255.0
Default Route: 10.0.2.2

========================================================================

When I was on my old laptop with Win7 it works well, it just fail on my new laptop with Win8.1. This is driving me crazy Orz. Plz HELP.

Re: Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 23. Aug 2015, 00:22
by Perryg
Starting with version 12.04 Ubuntu has changed the way that resolv.conf works. If you find that you cannot resolve friendly URLs in a guest (using VBox NAT) you need to switch the way VirtualBox provides the DNS information.

Try this (on the host) in a terminal/command window.

Code: Select all

VBoxManage modifyvm "VM name" --natdnshostresolver1 on
Replace the "VM name" with the name of your guest and don't forget the quotes " "

The above command is per VM. If you want to set this globally use the following in a host terminal.

Code: Select all

VBoxManage setextradata global natdnshostresolver1 on
Backup your VirtualBox.xml and the guests control file first in case you make a mistake.

Note: you need to actually be in the directory for the command to work ( Windows host only )

Re: Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 24. Aug 2015, 04:03
by kuanghongkai
Thanks for you help! But it still fails to connect.

After I try your approach, now I can resolve URLs, but the problem still exists. Neither typing a URL nor directly pasting an IP address in Firefox, it just complains that "Unable to connect" or "Server not found". It seems that it is not merely a problem of DNS.
Perryg wrote:Starting with version 12.04 Ubuntu has changed the way that resolv.conf works. If you find that you cannot resolve friendly URLs in a guest (using VBox NAT) you need to switch the way VirtualBox provides the DNS information.

Try this (on the host) in a terminal/command window.

Code: Select all

VBoxManage modifyvm "VM name" --natdnshostresolver1 on
Replace the "VM name" with the name of your guest and don't forget the quotes " "

The above command is per VM. If you want to set this globally use the following in a host terminal.

Code: Select all

VBoxManage setextradata global natdnshostresolver1 on
Backup your VirtualBox.xml and the guests control file first in case you make a mistake.

Note: you need to actually be in the directory for the command to work ( Windows host only )

Re: Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 24. Aug 2015, 13:38
by Perryg
At this point remote diagnostics is not going to work. I would use wireshark and see if you can tell what is actually happening. Being able to ping the IP but nothing can be found sounds like port filtering. Some firewalls can do this, usually virus scanners that have filters.

Re: Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 24. Aug 2015, 21:01
by kuanghongkai
I found a similar problem here [http://askubuntu.com/questions/566903/p ... lbox-guest][/url], saying that ping works because it uses ICMP protocol, which doesn't have a concept of ports, but that does not mean HTTP or FTP works. Is it relevant?

And today I installed a new guest os, CentOS 7. Same problem occured. Does it mean it is a problem with virtualbox rather than a problem inside VMs?

If so, where should I reconfigure virtualbox? Would it work if I simply reinstall the whole virtualbox and reload the VMs?

Perryg wrote:At this point remote diagnostics is not going to work. I would use wireshark and see if you can tell what is actually happening. Being able to ping the IP but nothing can be found sounds like port filtering. Some firewalls can do this, usually virus scanners that have filters.

Re: Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 24. Aug 2015, 21:29
by Perryg
Does it mean it is a problem with virtualbox rather than a problem inside VMs
If that were the case everyone would be having the same problem. You need to find what is blocking the port access. CentOS firewall rules default to not allow port access unless you enable them. You also have the host to worry about and as I said you should find out where the bottleneck is.

Re: Ubuntu 14.04 can ping everything, but connect to nothing

Posted: 26. Aug 2015, 13:00
by noteirak
If ping & DNS work, then your TCP link is working and the rest is blocked by firewall or related software.