44

I want my Raspberry Pi to use OpenDNS to resolve domain names. How can I modify this setting?

6 Answers6

52

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.

34

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
Justin
  • 571
19

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

Angs
  • 954
6

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

-2

The openDNS servers worked for me thanks. During a Udemy learning session I had run into a problem after ditching my wifi sharing arrangement with my Mac, and setting up ethernet hub with the PI on a different home network. The problem with my previous IP sharing arrangement with WiFi.

When I originally setup the PI with the sharing arrangement the text Inside the resolve file was:​

nameserver 192.168.2.1 

which was entered automatically by the minibian OS, NOT ME!

This IP became the default DNS server, with the MacMini seamlessly providing the real DNS in the background. ​

SO NEED TO EDIT(vim) WITH

nameserver  208.67.222.222
nameserver 208.67.220.220       

​Then I could ping google.com Thank goodness for forums!

SDsolar
  • 1,696
-3

Add this line into file /etc/dhcp/dhclient.conf:

option domain-name-servers 192.168.1.8, 8.8.8.8, 8.8.4.4

Then it will work.

user
  • 30,336
Larand
  • 1