Google DNS

Moderator: Forum moderators

Post Reply
ozsouth
Posts: 1569
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 241 times
Been thanked: 704 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: 1984
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2648 times
Been thanked: 692 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: 182
Joined: Sat Aug 01, 2020 7:44 pm
Has thanked: 1 time
Been thanked: 53 times

Re: Google DNS

Post by Trapster »

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

ozsouth
Posts: 1569
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 241 times
Been thanked: 704 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: 123
Joined: Tue Dec 19, 2023 10:12 am
Location: sitting in front of my terminal
Has thanked: 52 times
Been thanked: 37 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

Post Reply

Return to “Network”