Change DNS Servers Easily - Update 241124

Moderator: Forum moderators

Post Reply
User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Change DNS Servers Easily - Update 241124

Post by wizard »

This utility developed from methods described by @ozsouth and @Trapster in this post:
viewtopic.php?t=13082

A DNS server plays a critical role in connecting your computer to websites. It changes a URL name you type or select in your browser, i.e., amazon.com, into an IP address the internet understands.

For most users the DNS servers are assigned by the local router (automatic DHCP function). However, changing DNS servers may improve connect speed or security. In Puppy there are several ways to change servers including:

-logging into your router's interface and entering there, then all DHCP clients will use the new DNS
-assign the computer a static IP address and specify the DNS servers there (Network Wizard)
-manually create a /etc/resolv.conf.head file and specify the DNS servers there

Dns-changer.sh uses the third method and provides a GUI to make it quicker and easier

dns-changer.jpg
dns-changer.jpg (6.47 KiB) Viewed 1811 times

Dns-changer requires YAD which is included in most Pups or can be installed from the repositories on older versions.

UPDATE 241124
DNS-changer2a.pet is a minor revision of DNS-changer2. It does not add any functions, but the code is cleaner and it no longer calls the external script dns-restart2.sh. This makes the dns-changer2.sh main script more "portable" since it is stand alone.

See this post for download:
viewtopic.php?p=136442#p136442

UPDATE 241122
DNS-changer2.pet is a revision of dns-changer.sh that improves the following:
-adds a Menu>Network>DNS Changer item
-displays current DNS servers list
-works with SNS or Connman connection managers
-locks the DNS choices (resolv.conf) so the system cannnot randomly change them
NOTE: locking is only being honored by Conman connection manager, so if your connection is dropped and restarted (overwrites your choices) you can do a "Reset Previous"

Be sure to read this post: viewtopic.php?p=136277#p136277

Note: if you are using dns-restart.sh in /root/Startup, it should be removed.

Has only been tested on Puppys.

dns-changer2.pet
(1.32 KiB) Downloaded 99 times

""""""""""""""""""""""""""""""""""""""""""

Below only applies to original dns-changer

Download dns-changer.sh.gz, remove the .gz (rename)
-right click in Rox
-Permissions
-set as: a+x (Make executable/searchable)
-Yes
then click in Rox.

NOTE: After using dns-changer, you can check what server is being used at https://dnsleaktest.com/ , click "Standard test".

wizard

Attachments
dns-changer.sh.gz
Remove fake .gz before use
(828 Bytes) Downloaded 107 times
Last edited by wizard on Sun Nov 24, 2024 3:13 pm, edited 8 times in total.

Big pile of OLD computers

User avatar
Trapster
Posts: 184
Joined: Sat Aug 01, 2020 7:44 pm
Has thanked: 1 time
Been thanked: 55 times

Re: Change DNS Servers Easily

Post by Trapster »

Nice idea.
It might be handy to show the current nameservers when starting the script.

dogcat
Posts: 268
Joined: Fri Feb 18, 2022 11:14 pm
Has thanked: 76 times
Been thanked: 126 times

Re: Change DNS Servers Easily

Post by dogcat »

Thank You @wizard, I like this utility. It works as advertised :thumbup2:

Just an observation after trying this on 3 different linux versions from this forum.

The DNS changes stick after a reboot on FossaPup64 and FatDog64 when using a save file or save folder.

The changes won't stick after a reboot on BookwormPup64 when using a save file or save folder. That is because Connman defaults to the isp DNS settings when connecting to the internet. It has its configuration file at /etc/Connman/main.conf with a symlinked /etc/resolv.conf file. Changing BookwormPup64 to act differently is beyond the scope of your posting but figured I would mention it for those using BookwormPup64.

Μακάριοι οι καθαροί στην καρδιά * επειδή, θα δουν τον Θεό.

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@dogcat

The changes won't stick after a reboot on BookwormPup64 when using a save file or save folder. It has its configuration file at /etc/Connman/main.conf with a symlinked /etc/resolv.conf file

Good catch dc, although do not see the symlink you reference.

Here's a quick fix if you're using Conman in BW64.

Download dns-restart.sh.gz, remove the .gz (rename)
-right click in Rox
-Permissions
-set as: a+x (Make executable/searchable)
-Yes
Then copy into directory: /root/startup

Thanks
wizard

Attachments
dns-restart.sh.gz
Remove fake .gz before use
(167 Bytes) Downloaded 29 times
Last edited by wizard on Tue Nov 19, 2024 10:15 pm, edited 2 times in total.

Big pile of OLD computers

williwaw
Posts: 1973
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 372 times

Re: Change DNS Servers Easily

Post by williwaw »

-logging into your router's interface and entering there, then all DHCP clients will use the new DNS

Do DNS setting specified with at the router trump settings specified with this app?

-assign the computer a static IP address and specify the DNS servers there (Network Wizard)

Network Wizard available in Puppy? again, which would trump?

should results be immediate when apply is clicked and the yad comfirmation appears?
(testing on easy with network manager)

interesting project...
https://opennic.org/
https://servers.opennic.org/

and for testing
https://dnsleaktest.com/

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@williwaw

Do DNS setting specified with at the router trump settings specified with this app?

No, settings made in the computer are used.
241120 CORRECTION to above, test on additional routers show if STATIC DNS settings are made in the router they can override those in the computer.

Network Wizard available in Puppy? again, which would trump?

Yes, and same as above.

should results be immediate when apply is clicked and the yad comfirmation appears?

Yes

Thanks
wizard

Last edited by wizard on Wed Nov 20, 2024 6:18 pm, edited 4 times in total.

Big pile of OLD computers

User avatar
bigpup
Moderator
Posts: 7031
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 925 times
Been thanked: 1535 times

Re: Change DNS Servers Easily

Post by bigpup »

@wizard

For both of your script files to work.

After removing the fake .gz from the name, so it is script file.

They need to be given exec permission, so they will run when clicked on in Rox file manager.

suggest you add this to the info, on after downloading, how to make them work as an executable script file.

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
bigpup
Moderator
Posts: 7031
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 925 times
Been thanked: 1535 times

Re: Change DNS Servers Easily

Post by bigpup »

@wizard

A pet package can be attached to a post, as long as it is no bigger than 537KiB size.

Do you want to make the dns-changer into a pet package, that will install and have a menu entry to run it from?

As a pet package, all that is needed is download, install, and it runs. (names are correct and will have exec permissions)

I can do this for you, if you do not already know how to make a pet package of a program.

All that would be needed is figure out where in the file system to put the script file.
Make .desktop file to make a menu entry.
Figure out where in the menu would be good place for it.
Maybe menu ->Network or ->Internet :idea:

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@bigpup

suggest you add this to the info

Done

Do you want to make the dns-changer into a pet package

May do after all the votes are in and if there is more interest, right now only 10 downloads.

Thanks
wizard

Big pile of OLD computers

williwaw
Posts: 1973
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 372 times

Re: Change DNS Servers Easily

Post by williwaw »

running easyos which uses networkmanager
rebooted after setting router to accept ISP DNS and comfirmed DNS is with ISP

/etc/resolv.conf.head (as expected with new DNS as configured with dns-changer.sh and recieving a confirmation)

Code: Select all

nameserver 81.169.136.222
nameserver 81.169.136.222

/etc/resolv.conf before running dns-restart.sh

Code: Select all

# Generated by NetworkManager
search lan
nameserver 192.168.8.1
nameserver fd23:87ba:7394:10::1

/etc/resolv.conf after running dns-restart.sh

Code: Select all

# Generated by dhcpcd from wlan0.dhcp
nameserver 81.169.136.222
nameserver 81.169.136.222
domain lan
nameserver 192.168.8.1
# /etc/resolv.conf.tail can replace this line

return in terminal when running dns-restart

Code: Select all

0 /mnt/sda2/portable $ ./dns-restart.sh
killall: dhcpcd: no process killed
no such user dhcpcd
dhcpcd-9.4.1 starting
dev: loaded udev
DUID 00:04:8f:fd:4e:81:51:ee:11:cb:90:77:96:35:db:37:c8:54
wlan0: connected to Access Point: cisco
eth0: waiting for carrier
wlan0: IAID a9:64:3e:78
wlan0: soliciting an IPv6 router
wlan0: rebinding lease of 192.168.8.104
wlan0: probing address 192.168.8.104/24
wlan0: leased 192.168.8.104 for 43200 seconds
wlan0: adding route to 192.168.8.0/24
wlan0: adding default route via 192.168.8.1
forked to background, child pid 11018
0 /mnt/sda2/portable $ 

dns server doesnt change as confirmed with https://dnsleaktest.com/

ozsouth
Posts: 1588
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 246 times
Been thanked: 711 times

Re: Change DNS Servers Easily

Post by ozsouth »

@williwaw - I tested this script with ipv4 - is fine. I see you are using ipv6 - I now see there are different google servers for that:

2001:4860:4860::8888
2001:4860:4860::8844

Check with your ISP - the servers you used look like ipv4 ones.

williwaw
Posts: 1973
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 372 times

Re: Change DNS Servers Easily

Post by williwaw »

@ozsouth

ok, I plugged your numbers into dns-changer.sh and resolv.conf.head updated
ran dns-restart.sh and resolv.conf updated to

Code: Select all

# Generated by dhcpcd from wlan0.dhcp, wlan0.ra
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
domain lan
nameserver 192.168.8.1
nameserver fd23:87ba:7394:10::1
# /etc/resolv.conf.tail can replace this line

no change when checking with https://dnsleaktest.com/

commented out nameserver fd23:87ba:7394:10::1 from resolv.conf (thats the ipv6 entry?)
no change when checking with https://dnsleaktest.com/

I disconnected networkmanager and reconnected.
resolv.conf was rewritten to

Code: Select all

# Generated by dhcpcd from wlan0.dhcp
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
domain lan
nameserver 192.168.8.1
# /etc/resolv.conf.tail can replace this line

the commented out line was removed
now after a few minutes, aparently networkmanager is periodically updating resolv.conf. it now reads the same and the once commented out line that was removed is back again

Code: Select all

# Generated by dhcpcd from wlan0.dhcp, wlan0.ra
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
domain lan
nameserver 192.168.8.1
nameserver fd23:87ba:7394:10::1
# /etc/resolv.conf.tail can replace this line

if I use networkmanager to bring up connection information by right clicking on the taskbar icon, it reports
fe80::fe80:ee4e:dfef:cf9a/64
as IPv6

ozsouth
Posts: 1588
Joined: Sun Jul 12, 2020 2:38 am
Location: S.E. Australia
Has thanked: 246 times
Been thanked: 711 times

Re: Change DNS Servers Easily

Post by ozsouth »

@williwaw

running easyos which uses networkmanager . . .

. . . now after a few minutes, aparently networkmanager is periodically updating resolv.conf

I use s15pup64, which has the 'old 3' network choices. Sadly, periodic updating of resolv.conf will defeat this code.
I tried making a loop which would revert settings every minute or so, but that caused other issues.

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@williwaw

no change when checking with https://dnsleaktest.com/

Don't understand the significance of checking this as related to changing the DNS servers. Seems it would only apply if you were using a VPN or proxy. It just returns the WAN address of your router, that isn't affected by your DNS server choice.

Thanks
wizard

Big pile of OLD computers

williwaw
Posts: 1973
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 372 times

Re: Change DNS Servers Easily

Post by williwaw »

wizard wrote: Wed Nov 20, 2024 3:07 am

@williwaw

no change when checking with https://dnsleaktest.com/

Don't understand the significance of checking this as related to changing the DNS servers. Seems it would only apply if you were using a VPN or proxy. It just returns the WAN address of your router, that isn't affected by your DNS server choice.

Thanks
wizard

it returns a DNS owned by the ISP. The router has had the manual DNS config turned off, and I assume DHCP is automatic. the leaktest site does seem to advertise its self to people who may be using VPNs or proxys.

I have found a few dns servers who also filter malware and blacklist ads, less trouble than a custom hosts or browser addons

Looking further into NetworkManager, apparently there are multiple instructions to be found online as to how to get NetworkManager apply static configs. A number of different attempts have not worked thus far. As I recall, there was a reason I resorted to putting the desired DNS into a manual mode on the router a few years back. As far as I can tell, It trumps any configurations supplied with various pups, other linuxes or Easy

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@williwaw

I have found a few dns servers who also filter malware and blacklist ad

Yes, some very useful but they don't change your WAN address. If they did they would be acting as a VPN or Proxy, by definition.

I resorted to putting the desired DNS into a manual mode on the router a few years back. As far as I can tell, It trumps any configurations supplied with various pups, other linuxes or Easy

Just the opposite on my three routers where the DNS settings on the Pup computer are always superior. Don't know for Easy or other Linux.
241120 CORRECTION to above, test on additional routers show if STATIC DNS settings are made in the router they can override those in the computer.

My mistake on using https://dnsleaktest.com/. Was only looking at the home page which shows your WAN address. If you click the "Standard test" button you will now see what DNS server is being used.
Here's an example:

DNS servers before using dns-changer (uses DNS settings in router)

dns-before.jpg
dns-before.jpg (17.58 KiB) Viewed 1500 times

DNS servers after using dns-changer set to 1.1.1.1 & 8.8.8.8 (now uses DNS settings in computer)

dns-after.jpg
dns-after.jpg (13.18 KiB) Viewed 1500 times

Now that's really useful, will add a note to the first post.

Thanks
wizard

Last edited by wizard on Wed Nov 20, 2024 6:18 pm, edited 1 time in total.

Big pile of OLD computers

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@williwaw

Did some more testing on some additional routers and showed if STATIC DNS settings are made in the router they can override those in the computer. Not every case on mine, so probably due to my configuration.

I've gone back and made a clarification correction on affected post.

Thanks
wizard

Big pile of OLD computers

darksun
Posts: 128
Joined: Tue Dec 19, 2023 10:12 am
Location: behind a vpn
Has thanked: 53 times
Been thanked: 39 times

Re: Change DNS Servers Easily

Post by darksun »

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@williwaw

Lots more testing, lots of variables for this including:
-distro
-router and DNS settings
-Browser
-Connecton manager

At first, test results were erratic and not repeatable, never a good sign. The ah-ha moment was.....the browsers were caching the DNS server addresses. So, here is what gives repeatable results:

-if you change ANYTHING about the connections, i.e., router, ethernet, wifi, etc you must reset the DNS servers

-if you change the DNS servers you MUST completely clear your browser cache. @mikewalsh Chromium Portable was used and allows this on shutdown

After changing servers you can check the changes in the computer:
-in terminal type: nslookup host (will show the first server to be tried)
-in terminal type: cat /etc/resolv.conf (will show all servers to be tried)

After clearing your browser cache, you can test what actual server is being used at:
https://www.top10vpn.com/tools/what-is-my-dns-server/

Here is a series of test on one of my routers, in this case all test show the DNS servers set in the computer overrides ones set in the router. YMMV.

DNStest2.jpg
DNStest2.jpg (46.04 KiB) Viewed 1333 times

If you follow the guidelines above you should be able to test your own configurations.

Thanks
wizard

Big pile of OLD computers

williwaw
Posts: 1973
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 372 times

Re: Change DNS Servers Easily

Post by williwaw »

wizard wrote: Thu Nov 21, 2024 10:33 pm

-if you change ANYTHING about the connections, i.e., router, ethernet, wifi, etc you must reset the DNS servers

this seems prudent, especially if the browser is storing info

After changing servers you can check the changes in the computer:
-in terminal type: nslookup host (will show the first server to be tried)
-in terminal type: cat /etc/resolv.conf (will show all servers to be tried)

seems good. this is what I see with a networkmanager generated resolv.conf

Code: Select all


0 ~ $ nslookup host 
Server:		192.168.8.1
Address:	192.168.8.1:53

** server can't find host.lan: NXDOMAIN

** server can't find host.lan: NXDOMAIN

1 ~ $ cat /etc/resolv.conf 
# Generated by NetworkManager
search lan
nameserver 192.168.8.1
nameserver fd23:87ba:7394:10::1
0 ~ $ 

just adding what I can, I realize including support for networkmanager is probly beyond the scope of your present efforts

The computer trumps router settings with the cisco. Have you tried many different routers?
mine is a gl-inet sprite. maybe gl-inet is an outlier.

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

@williwaw

The computer trumps router settings with the cisco. Have you tried many different routers?

Yes, my TP-Link AC1750 gives the same results, computer trumps router.

What distro are you using with net manager?

Thanks
wizard

Big pile of OLD computers

williwaw
Posts: 1973
Joined: Tue Jul 14, 2020 11:24 pm
Has thanked: 172 times
Been thanked: 372 times

Re: Change DNS Servers Easily

Post by williwaw »

I'm using QV at the moment. It uses NetworkManager as does EasyOs for quite a while now.
As you can see, NetworkManager writes a resolv.conf that points to my router. 192.168.8.1

I have no idea what nameserver fd23:87ba:7394:10::1 does in the second line

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily

Post by wizard »

DNS-changer2.pet is released in the first post.
Improves the following:
-adds a Menu>Network>DNS Changer item
-displays current DNS servers list
-works with SNS or Connman connection managers
-locks the DNS choices (resolv.conf) so the system cannnot randomly change them
NOTE: locking is only being honored by Conman connection manager, so if your connection is dropped and restarted (overwrites your choices) you can do a "Reset Previous"

Thanks
wizard

Big pile of OLD computers

User avatar
wizard
Posts: 1993
Joined: Sun Aug 09, 2020 7:50 pm
Has thanked: 2667 times
Been thanked: 694 times

Re: Change DNS Servers Easily - Update 241122

Post by wizard »

241124

DNS-changer2a.pet is a minor revision of DNS-changer2. It does not add any functions, but the code is cleaner and the main script no longer calls the external script dns-restart2.sh. This makes the dns-changer2.sh main script more "portable" since it is stand alone.

resetdns.jpg
resetdns.jpg (7.49 KiB) Viewed 975 times
dns-changer.jpg
dns-changer.jpg (6.47 KiB) Viewed 975 times

wizard

Attachments
dns-changer2a.pet
(1.31 KiB) Downloaded 122 times

Big pile of OLD computers

SteveS
Posts: 14
Joined: Tue Sep 24, 2024 4:00 pm
Been thanked: 3 times

Re: Change DNS Servers Easily - Update 241124

Post by SteveS »

This is great.

For EasyOS I created a custom script resolv-conf-set saved in /root/Startup/. This was not better but it keeps a trace of previous assigned nameservers (commenting their lines).

Code: Select all

#!/bin/sh
sleep 8
sed -i '/nameserver/ s/^/#/' /etc/resolv.conf
echo "
# Generated by /root/Startup/resolv-conf-set
nameserver 1.1.1.1" >> /etc/resolv.conf

Then making it executable with chmod 755 /root/Startup/resolv-conf-set

I confirm that dns-changer2a.pet works well in EasyOS.

Post Reply

Return to “Network/Server”