23

I can't ping google.com (unknown host). But I can ping IP addresses. I tried to ping the IP address of Google but it doesn't work.

  • resolv.conf

    nameserver 8.8.8.8 nameserver 209.139.209.33 
    
  • ifconfig -a

    eth0      Link encap:Ethernet  HWaddr 00:50:56:xx:xx:xx
              inet addr:10.2.0.63  Bcast:10.2.15.255  Mask:255.255.240.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:638762803 errors:0 dropped:0 overruns:0 frame:0
              TX packets:231307131 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:55502371533 (51.6 GiB)  TX bytes:23436883491 (21.8 GiB)
    
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:56011078 errors:0 dropped:0 overruns:0 frame:0
              TX packets:56011078 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:4792283266 (4.4 GiB)  TX bytes:4792283266 (4.4 GiB)
    
  • route -n

    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    10.2.0.0        0.0.0.0         255.255.240.0   U     0      0        0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
    0.0.0.0         10.2.15.1       0.0.0.0         UG    0      0        0 eth0
    
  • ping -c 4 -n 8.8.8.8

    4 packets transmitted, 0 received, 100% packet loss, time 13000ms
    
Runium
  • 28,133
  • 5
  • 50
  • 71
az93
  • 857
  • 4
  • 9
  • 9
  • 2
    You might look for `/etc/resolv.conf` in the manpages or the Internet search engines. – 41754 Jan 15 '14 at 08:56
  • 1
    add the content of your `resolve.conf` file it's really hard to help you with so short info. having the result of `ipconfig -a` can also be nice – Kiwy Jan 15 '14 at 09:04
  • I can't ping 80.81.183.175 – az93 Jan 15 '14 at 09:25
  • resolv.conf nameserver 8.8.8.8 nameserver 209.139.209.33 – az93 Jan 15 '14 at 09:26
  • can you `ping 8.8.8.8` I also don't know your network environement are you at work or in University or things like that ? because outside ping could also be disable in this case and a better test would be `wget 173.194.65.94` (one of the google's IP). Please also add to your question the result of `route -n` – Kiwy Jan 15 '14 at 09:30
  • I can't ping 8.8.8.8 or 8.8.8.4. And I can't connect to the IP adress.I am in a company (intenship/training course : i don't know how to say it in english) – az93 Jan 15 '14 at 09:39
  • Please [edit] your question to include the output specific of `ping -c 4 -n 8.8.8.8` Also, try wget as suggested by @Kiwy above. – user Jan 15 '14 at 09:49
  • 4 packets transmitted, 0 received, 100% packet loss, time 13000ms. And wget doesn't work. – az93 Jan 15 '14 at 09:53
  • 2
    Well you have no internet connectivity eitheir comming from your network settings you probably need a proxy as your currently in a company. @az93 a last test can be `traceroute 8.8.8.8` – Kiwy Jan 15 '14 at 09:55
  • It is maybe because of the gateway no ? – az93 Jan 15 '14 at 09:59
  • traceroute doesn't work either – az93 Jan 15 '14 at 10:00
  • we need the output on your question @az93 – Kiwy Jan 15 '14 at 10:03
  • I can't ping any IP adress – az93 Jan 15 '14 at 10:09
  • @az93 please provide the output of the traceroute. Does the cable plug inside your ethernet port ? is it your machine ? because there's already several gigabyte transfer from the `eth0`. – Kiwy Jan 15 '14 at 10:19
  • Traceroute: command not found. – az93 Jan 15 '14 at 10:21
  • I had a similar issue, but in Solaris - http://unix.stackexchange.com/questions/99211/cannot-connect-to-internet-but-can-ssh-into-solaris-x86-vs-11, maybe try and see if that will help? – Kevdog777 Jan 15 '14 at 10:25
  • I use a cacti server on Putty if that can help – az93 Jan 15 '14 at 10:27
  • 1
    by the way resolv.conf should contain one entry per line – SamK Jan 20 '14 at 14:07
  • I had a similar problem to this and it was caused by IPV6 being enabled. What I did is disabled my IPV6. Or alternatively you can add the IPV6 DNS in the name servers. – Artanis Zeratul Jan 11 '22 at 21:04

6 Answers6

5

If you can reach something by IP but not by name, then something's wrong with DNS lookup: your machine cannot find the IP address by name. Other than that, your networking and routing setup seems fine.

Things that could cause this:

  • DNS server down
  • Misconfigured of /etc/resolv.conf
  • Misconfigured of /etc/nsswitch.conf
  • ...

And probably others, but the first two are the most typical.

  • What's the nameserver in your network? Find out its name and IP address.
  • Can you ping it by IP address? If you cannot then it's down.
  • Is the nameserver correct in /etc/resolv.conf? If not then you need to add a line for it, for example: nameserver THE_IP
  • Is the nameserver dynamically set by DHCP in your network? If yes then you shouldn't mess with /etc/resolv.conf, it should be all automatic, and it looks like something's wrong at your provider's end.
janos
  • 11,171
  • 3
  • 35
  • 53
  • The contents of resolv.conf nameserver 8.8.8.8 nameserver 209.139.209.33 – az93 Jan 15 '14 at 09:25
  • How do you know that `209.139.209.33` is correct for you? Can you ping it? – janos Jan 15 '14 at 09:37
  • No I can't, but I asked in an other forum and they said to me to put these address – az93 Jan 15 '14 at 09:46
  • I manually set my address using the gui network manager tool. For whatever reason it wasn't updating my `resolve.conf` with my `nameserver` so I had to add it manually. FYI This is a basic home network so the `nameserver` was the same my `gateway` from `ifconfig`. – Jacksonkr Nov 07 '16 at 15:16
3

This is a Google specific thing. I was just reading about this very issue in Google Groups. Apparently, when volumes of certain packet types are too high Google silently discards them. 8.8.8.8 is one of Google's public DNS servers and is well known for appearing to be down when it is in fact simply ignoring surplus (non-DNS) requests.

1

Looking at your IP configuration:

eth0      Link encap:Ethernet  HWaddr 00:50:56:xx:xx:xx
          inet addr:10.2.0.63  Bcast:10.2.15.255  Mask:255.255.240.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:638762803 errors:0 dropped:0 overruns:0 frame:0
          TX packets:231307131 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:55502371533 (51.6 GiB)  TX bytes:23436883491 (21.8 GiB)

Try changing the Bcast to 10.2.255.255 and Mask to 255.0.0.0

Open terminal and type the following command:

sudo vi /etc/network/interfaces

Find eth0 section and setup IP address as follows:

auto eth0
iface eth0 inet static
address 10.2.0.63
netmask 255.0.0.0
broadcast 10.2.255.255

Save and close the file. Once done, restart network:

$ sudo /etc/init.d/networking restart

Verify new IP address:

$ ifconfig eth0
$ ifconfig
Kevdog777
  • 3,194
  • 18
  • 43
  • 64
0

Since you have not shown your /etc/network/interfaces file this option is valid. Try changing from the static configuration to dhcp and run ping google.com. If it works then maybe another device has already the Ip you requested.

run nmap 10.2.0.* and check the available adresses.

I had the same issue and I couldn't figure out what the problem was. I checked the device connected to the router and found out that a maudit Android device had the ip I wrote in the interfaces file. I just changed it, and it worked.

Rui F Ribeiro
  • 55,929
  • 26
  • 146
  • 227
UserK
  • 2,334
  • 5
  • 21
  • 25
0

The error you cannot ping www.google.com saying unknown host can be because the DNS resolution is not happening correctly. This may be because you have incorrectly configured DNS in your resolve.conf file. But as mentioned in the question if even the IP address of google cannot be ping then there may be an error of the configuration in the gateway in the /etc/network/interfaces file.

gowther
  • 1
  • 1
-2

Execute this command to ping to google ( or any other site )

sudo echo "nameserver 8.8.8.8" >> /etc/resolv.conf

SHW
  • 14,454
  • 14
  • 63
  • 101
  • 8
    Don't do this without asking yourself if you want google to resolv every DNS request you make. You can ans should consider other free DNS like openDNS or maybe the DNS of your internet provider. Google 8.8.8.8 DNS is still a very good way to debug DNS issue. – Kiwy Jan 15 '14 at 09:21
  • It doesn't changes. I still can't ping. – az93 Jan 15 '14 at 09:47
  • Why you are pinging to 8.8.8.8 ??? After adding `nameserver 8.8.8.8`, what is the output of `ping google.com` ? – SHW Jan 15 '14 at 10:02
  • After adding nameserver 8.8.8.8, I still can't ping google. – az93 Jan 15 '14 at 10:08
  • Can you give us more info on the output of "can't ping Google", please? Like just paste the actual line from PuTTy, as a comment - that is what @SHW was asking. – Kevdog777 Jan 15 '14 at 10:37
  • 1
    OK, excuse me I don't speak english very well. It's written : ping: unknown host google.com. This is what you wanted ? – az93 Jan 15 '14 at 10:43
  • Paste the output of `ping google.com -c 3` and `ping 173.194.117.6 -c 3` – SHW Jan 15 '14 at 10:45
  • Yeah thanks, I understand your English is not that good. Just trying to help you mate. – Kevdog777 Jan 15 '14 at 10:46
  • ping google.com -c 3 :unknown host google.com and ping 173.194.117.6 -c 3 3 packets transmitted, 0 received, 100% packet loss, time 11999ms – az93 Jan 15 '14 at 10:49
  • Great. Said IP is of google.com Now to which IP (which is of google, as per you) you are *successfully* pinging ? – SHW Jan 15 '14 at 10:51