7

Can't connect to www.google.com even being connected to the Internet.

I always need to change the DNS to 8.8.8.8 in /etc/resolv.conf but it changes automatically into 127.0.0.1 and then www.google.com do not work.

Bex
  • 2,929
  • 3
  • 26
  • 34
Niz.Dam
  • 325
  • 3
  • 4
  • 11

2 Answers2

12

I had the problem that my raspberry 3 couldn't connect to inet, but it had connection (no ping to google.com but it had ping to the ip address). So I figured it was a DNS problem. After a search I found this solution. Sorry, but I don't remember where, so I can't post the link.

It's true that /etc/resolv.conf is created at every reboot, so you lose the changes you make.

A solution is to create a file in /etc named resolv.conf.head

sudo nano resolv.conf.head

and then put there the lines with the dns servers you want. For example, for google and OpenDns:

#Google DNS
nameserver 8.8.8.8

#OpenDns Servers nameserver 208.67.222.222 nameserver 208.67.220.220

The lines you write in this file are automatically added to resolv.conf when it is generated.

Caresth
  • 121
  • 4
9

Edit /etc/network/interfaces file and add the following to the end:

dns-nameservers 8.8.8.8

Don't edit /etc/resolv.conf since that file is generated automatically.

rsp
  • 622
  • 1
  • 6
  • 16