How do I set DNS Servers on Raspberry Pi?
If you are using Debian on Raspberry Pi, then you need to edit /etc/resolv.conf
nano /etc/resolv.conf
then add the server IP of the openDNS
nameserver 208.67.222.222
nameserver 208.67.220.220
Btw, if you have any concern about speed of the DNS you may want to take a look at this post
I've found that in the latest version of Raspbian (stretch I think?) you now need to edit the last line of /etc/dhcpcd.conf
. There should be a line that starts with static domain_name_servers=
- there you can customise it with a list of space-separated DNS servers, like this:
static domain_name_servers=1.1.1.1 1.0.0.1 208.69.38.205 8.8.8.8
DNS Servers Featured: Cloudflare, OpenDNS, and Google
Edit: As @DavidOliver points out, you may need to restart dhcpcd too: sudo systemctl restart dhcpcd.service
.
Don't edit /etc/resolv.conf
since that file is generated automatically. Instead edit /etc/network/interfaces
and add the following to the end:
dns-nameservers 8.8.4.4 8.8.8.8
I have found the answer from another website and this is the best. I used the very last part of the article as Raspbian comes with dchpcd already installed and i still want an automatic ip address not a static ip address. Running from a Raspberry Pi3 multiboot [berryboot] with Raspbian - Pixel type
sudo nano /etc/resolv.conf.head
in your terminal. You will have a blank slate to work with. Next copy and paste the following code:
#OpenDns Servers
nameserver 208.67.222.222
nameserver 208.67.220.220
click on cntrl + x to exit out and select y for the following options to save. restart your Raspberry Pi with
sudo reboot
To make sure you are using OpenDNS go to the following website: OpenDns welcome page