Google DNS

Moderator: Forum moderators

Post Reply
ozsouth
Posts: 1668
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 252 times
Been thanked: 754 times

Google DNS

Post by ozsouth »

I made a script to set google ipv4 dns as nameservers. Enables faster surfing & is apparently secure
- see: https://developers.google.com/speed/pub ... docs/intro (also has ipv6 info).
It needs to run after dhcp has set it's default.

16Nov24 EDIT: simpler, ok solution is 3 posts down.

As I have a savefolder, to make it run after dhcp settings, I needed a sleep 8 (may need 12)
To make it run last & not hold up other processes, I called it zsetresgoo , made it executable & put it in /root/Startup
The first echo overwrites resolv.conf & the second echo appends that file

Code: Select all

#!/bin/sh
sleep 8
echo nameserver 8.8.8.8 > /etc/resolv.conf
echo nameserver 8.8.4.4 >> /etc/resolv.conf

An issue - if you suspend (i.e. close laptop lid), upon resume, previous settings return. A hack fix is to add the
following code to the end of /etc/acpi/actions/suspend.sh (optimal timings can vary with different pcs)

Code: Select all

sleep 16
echo nameserver 8.8.8.8 > /etc/resolv.conf
echo nameserver 8.8.4.4 >> /etc/resolv.conf
Last edited by ozsouth on Sat Nov 16, 2024 12:41 am, edited 4 times in total.
User avatar
wizard
Posts: 2086
Joined: Sun Aug 09, 2020 7:50 pm
Location: Oklahoma, USA
Has thanked: 2837 times
Been thanked: 753 times

Re: Google DNS

Post by wizard »

@ozsouth

Have my DNS server choice set in my router, then all DHCP devices use that. Otherwise, if you set a static IP you can specify the DNS there.

Thanks
wizard

Big pile of OLD computers

User avatar
Trapster
Posts: 201
Joined: Sat Aug 01, 2020 7:44 pm
Location: Texas
Has thanked: 1 time
Been thanked: 61 times

Re: Google DNS

Post by Trapster »

Isn't that what /etc/resolv.conf.head and /etc/resolv.conf.tail is for?

ozsouth
Posts: 1668
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 252 times
Been thanked: 754 times

Re: Google DNS

Post by ozsouth »

@Trapster - sort of. I wanted to obliterate the original settings (mine picks the router ip & 0.0.0.0).

Making file /etc/resolv.conf.head , containing just

nameserver 8.8.8.8
nameserver 8.8.4.4

gives google dns priority, but system could possibly use the original lame duck entries.

Note, to activate changes, need to reboot with save, or run in terminal: killall dhcpcd then dhcpcd

As it is simpler for most folk overall, yes, I now recommend using /etc/resolv.conf.head

darksun
Posts: 170
Joined: Tue Dec 19, 2023 10:12 am
Has thanked: 55 times
Been thanked: 66 times

Re: Google DNS

Post by darksun »

DNS wise, I also would recommend to take in consideration:

- using the operating system's default network manager as main way to manage them, this in order to avoid possible situation where the system DNSs get overwritten by it in some scenarios;

- https://www.privacyguides.org/en/dns/ a source of private secure and fast DNS resolvers

- local encrypted DNS stub resolver, such as :

Code: Select all

apt install stubby

leafpad /etc/stubby/stubby.yml

SteveS
Posts: 38
Joined: Tue Sep 24, 2024 4:00 pm
Has thanked: 1 time
Been thanked: 12 times

Re: Google DNS

Post by SteveS »

Now, there is an easier way to change DNS Servers with a .pet created by @wizard here:
viewtopic.php?t=13135

I hope this helps.

Post Reply

Return to “Network”