Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set DNS servers manually?

How do I exclude DNS from the DHCP lease request on a Raspberry Pi?

I tried updating /etc/resolv.conf but it's reset after a while.

Reason: I am on a home network, and the home router uses itself as the DNS server, but the router's DNS service isn't working properly sometimes.

like image 967
Old Geezer Avatar asked Nov 10 '15 03:11

Old Geezer


People also ask

Is 1.1 1.1 still the fastest DNS?

The independent DNS monitor DNSPerf ranks 1.1.1.1 the fastest DNS service in the world. Since nearly everything you do on the Internet starts with a DNS request, choosing the fastest DNS directory across all your devices will accelerate almost everything you do online.

Should I use 8.8 8.8 DNS?

That is not recommended and may even be a violation of your security policies, depending on the level of security required in your organization or by any governing agency. DNS forwarders that only point to 8.8. 8.8 are using your ISP connection to hop to 8.8. 8.8 when resolving DNS.

What does changing your DNS to 8.8 8.8 do?

8.8. 8.8 is a public DNS recursive operated by Google. Configuring to use that instead of your default means that your queries go to Google instead of to your ISP.

What is the 8.8 4.4 DNS server?

8.8. 4.4 is the secondary DNS server for Google Public DNS. Google Public DNS is a global DNS service that is run by Google for the purpose of making the Internet and the DNS system faster, safer, secure, and more reliable for everyone online.


2 Answers

Most of the answers didn't work for me, but I found that this worked:

sudo vi /etc/dhcpcd.conf

Added a line (note that there is no comma):

static domain_name_servers=8.8.8.8 8.8.4.4

And unplugged and replugged my ethernet cable, which updates the resolver...

cat /etc/resolv.conf

Now shows:

# Generated by resolvconf
domain example.com
nameserver 8.8.8.8
nameserver 8.8.4.4

This also a better way to fix the problem where changes to /etc/resolv.conf are lost on reboot.

like image 144
Tony Allan Avatar answered Sep 23 '22 15:09

Tony Allan


I asume the problem is, that the dhcpclient is getting new information about DNS servers with every dhcp-renewal. Add this line into /etc/dhcp/dhclient.conf:

option domain-name-servers 192.168.1.8, 8.8.8.8, 8.8.4.4

Of course you should replace the ip-addresses with the ones from your demanded DNS server. Probably restart the according service.

like image 31
OLeh Avatar answered Sep 23 '22 15:09

OLeh