DEV Community

Cover image for Raspberry Pi DNS Settings Update 🔌
Stan Kukučka
Stan Kukučka

Posted on

Raspberry Pi DNS Settings Update 🔌

Enter Raspberry Pi with SSH.

Let's connect to Raspberry Pi over SSH with this simple command and then enter the password we keep for that whatever is your device connected over WIFI or via UTP cable.

ssh pi@raspberrypi.local
Enter fullscreen mode Exit fullscreen mode

Modify DNS info

Go to a specific configuration file named dhcpcd and edit it via nano command.

sudo nano /etc/dhcpcd.conf
Enter fullscreen mode Exit fullscreen mode

Look for the static domain_name_servers string that at the beginning holds the # sign. It means the whole string is commented in other words not used as a command. Remove commenting sign as # and edit whole domain name server as you wish. You can go with Google's Public DNS servers that stay for 8.8.4.4. and 8.8.8.8 or select Public DNS servers on Cloudflare that stays for 1.1.1.1. Choose just one provider to paste. So based on your preference you will edit the whole string as follows. In the end, the whole string should look like this for Cloudflare's option.

static domain_name_servers=1.1.1.1
Enter fullscreen mode Exit fullscreen mode

Or like this for Google's option.

static domain_name_servers=8.8.4.4 8.8.8.8
Enter fullscreen mode Exit fullscreen mode

Press CTRL + X and as you'll be asked to "Save modified buffer?" press Y and then ENTER. No need to restart the whole Raspberry Pi device, just restart the dhcpcd service.

sudo service dhcpcd restart
Enter fullscreen mode Exit fullscreen mode

To check if the domain name server's update was accepted and passed correctly use this last command to execute resolv file.

sudo nano /etc/resolv.conf
Enter fullscreen mode Exit fullscreen mode

You should be seeing something like # Generated by resolvconf info and under it nameserver updated informations. That's all.

Thank your lucky stars. Reading this whole DNS-awesomesauce brief tutorial.

Thanks to Taylor Vick for the cover image from Unsplash.

Top comments (0)