Sunday, August 3, 2014

How to fix when Raspberry Pi cannot resolve DNS to IP address

I don't know why my Pi was having the issue; I have never had it before.
But it was not able to resolve DNS to IP address; in other words, I couldn't ping to google.com
It is actually very easy to fix and I am posting this for people who may have the same issue later.

Make sure your file, /etc/resolv.conf, has proper DNS servers. Most of time, your Internet Service Providers will provide at least one server automatically. But I use Google's DNS: their IP numbers are 8.8.4.4 and 8.8.8.8. They are reliable and easy to remember. Also unintuitive they are faster than what IPS gives you.
pi@desktoppi ~ $ ping google.com
ping: unknown host google.com
pi@desktoppi ~ $ cat /etc/resolv.conf 

pi@desktoppi ~ $ sudo vi /etc/resolv.conf
pi@desktoppi ~ $ cat /etc/resolv.conf 
nameserver 8.8.8.8
nameserver 8.8.4.4
pi@desktoppi ~ $ ping google.com
PING google.com (70.186.26.52) 56(84) bytes of data.
64 bytes from 70.186.26.52: icmp_req=1 ttl=57 time=11.3 ms
64 bytes from 70.186.26.52: icmp_req=2 ttl=57 time=14.8 ms
64 bytes from 70.186.26.52: icmp_req=3 ttl=57 time=20.6 ms
^C64 bytes from 70.186.26.52: icmp_req=4 ttl=57 time=11.1 ms

--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 15440ms
rtt min/avg/max/mdev = 11.185/14.496/20.603/3.817 ms
pi@desktoppi ~ $ 

Modify the file, /etc/resolv.conf, and add two lines below like the screenshot above:
nameserver 8.8.8.8
nameserver 8.8.4.4

And test it if you can resolve DNS to IP address with "ping google.com"

1 comment:

  1. This blog is nice and very informative. I like this blog. blogPlease keep it up.

    ReplyDelete

About Me

My photo
Tomorrow may not come, so I want to do my best now.