[SOLVED] Permanent Change to DNS (Dynamic Nameserver)

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
zaileion
Level 4
Level 4
Posts: 297
Joined: Sun Jan 25, 2015 6:01 pm

[SOLVED] Permanent Change to DNS (Dynamic Nameserver)

Post by zaileion »

Before I begin with my issue I have to just voice a bit of disbelief first. Verizon is my carrier because I only have 2 choices for carriers here in the Philly area, You believe that!? 2 carriers in the entire Mid-Atlantic region of the USA. Talk about a monopoly.. Time for a political revolution in this country. Peaceful or otherwise...

OK my issue follows.

I’m trying to make permanent changes to my DNS settings. Verizon is my current default DNS and I want to switch. I’ve tried several different procedures suggested from Google search but my DNS keeps switching back to Verizon after a while. I don’t know if its after a reboot, or browser restart or what the catalyst is for the switch back but it keeps switching back.

Ive tried the following procedures.

Link: http://ubuntuforums.org/showthread.php?t=2078398

Link says to: (I changed gedit to pluma)

Code: Select all

gksudo gedit /etc/resolv.conf
or

Code: Select all

gksudo gedit /etc/resolvconf/resolv.conf.d/head
or

Code: Select all

sudo pluma /etc/network/interfaces
None of them take.

Link: http://unix.stackexchange.com/questions ... untu-14-04

Says to:

I changed vim to pluma

Code: Select all

sudo vim /etc/resolvconf/resolv.conf.d/base


Then:

Code: Select all

$ sudo resolvconf –u
etc/resolvconf/update.d/libc:
Warning: /etc/resolv.conf is not a symbolic link to /etc/resolvconf/run/resolv.conf
$
Still nothing takes permanently.

Ive also tried

Link: http://forum.linuxmint.com/viewtopic.php?f=157&t=139969
Says basically the same procedures as above...

I've also tried the GUI Network Manager thing in the systray but that doesn't work either...

So what is the proper and current procedure to make permanent changes to DNS?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
kukamuumuka

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by kukamuumuka »

You need to write-protect the file. An example:
1. Disconnect
2. Run
Mint 13

Code: Select all

sudo nano /etc/resolv.conf
Mint 17

Code: Select all

sudo nano /run/resolvconf/resolv.conf
... the contents

Code: Select all

nameserver 8.8.8.8
... save and quit
Ctrl o
Ctrl x
3. write-protect the file
Mint 13

Code: Select all

sudo chattr +i /etc/resolv.conf
Mint 17

Code: Select all

sudo chattr +i  /run/resolvconf/resolv.conf
4.Connect
Last edited by kukamuumuka on Fri Aug 21, 2015 2:24 am, edited 1 time in total.
zaileion
Level 4
Level 4
Posts: 297
Joined: Sun Jan 25, 2015 6:01 pm

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by zaileion »

1.
Disable network (I right clicked Network Manager in systray and removed check form Enable Network LMDE2 Mint)

2.
In mate-terminal (click menu and click Terminal)

Code: Select all

sudo nano /etc/resolv.conf
Enter this into file

Code: Select all

nameserver 8.8.8.8
Save and Quit
Ctrl o
Ctrl x

3.
Type below command into the Termional to write protect the file resolv.conf
by

Code: Select all

sudo chattr +i /etc/resolv.conf
My result of the following command:

Code: Select all

$ sudo chattr +i /etc/resolv.conf
chattr: Operation not supported while reading flags on /etc/resolv.conf
$
Any Ideas?
Laurent85
Level 17
Level 17
Posts: 7081
Joined: Tue May 26, 2015 10:11 am

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by Laurent85 »

Note your current IPv4 settings using nm-tool command in a terminal.

Launch Network Connections tool. Edit your connexion :
- IPV4 Settings tab, select Method Manual
- Add your address, prefix and gateway according to nm-tool settings
- DNS Servers: set IP addresses of your DNS servers of choice, use commas to seperate multiple IP's.
- save
- disconnect network interface, reconnect
- check your new settings using nm-tool command.
Image
User avatar
Pjotr
Level 24
Level 24
Posts: 20123
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by Pjotr »

By coincidence I've had to dig into this matter today myself, because the DNS name server of my internet service provider was down because of a DDOS attack.... As usual, I've written the solution that I've found on my website, both as a reminder for myself and as a help for others. :)

So, this is how you do it:
https://sites.google.com/site/easylinux ... our-system
(item 11, right column)

That how-to has been written primarily for adding name servers as *reserve*, but the bold text at the end describes the difference in procedure for adding a new name server that should become the *default*.
Last edited by Pjotr on Fri Aug 21, 2015 5:57 am, edited 1 time in total.
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
zaileion
Level 4
Level 4
Posts: 297
Joined: Sun Jan 25, 2015 6:01 pm

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by zaileion »

Post by Pjotr on Thu Aug 20, 2015 5:57 pm worked for me! Thank You!
kukamuumuka

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by kukamuumuka »

zaileion wrote: by

Code: Select all

sudo chattr +i /etc/resolv.conf
My result of the following command:

Code: Select all

$ sudo chattr +i /etc/resolv.conf
chattr: Operation not supported while reading flags on /etc/resolv.conf
$
Any Ideas?
In Mint 17 the file is /run/resolvconf/resolv.conf

Code: Select all

sudo chattr +i /run/resolvconf/resolv.conf
User avatar
Pjotr
Level 24
Level 24
Posts: 20123
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by Pjotr »

zaileion wrote:Post by Pjotr on Thu Aug 20, 2015 5:57 pm worked for me! Thank You!
You're welcome! :)

Finally a word of caution: the owner of the DNS has the ability to see, log and profile all of your internet traffic! So be careful when you select another DNS.
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
altair4
Level 20
Level 20
Posts: 11458
Joined: Tue Feb 03, 2009 10:27 am

Re: Permanent Change to DNS (Dynamic Nameserver)

Post by altair4 »

This is more an anecdotal comment but:
Laurent85 wrote:Note your current IPv4 settings using nm-tool command in a terminal.

Launch Network Connections tool. Edit your connexion :
- IPV4 Settings tab, select Method Manual
- Add your address, prefix and gateway according to nm-tool settings
- DNS Servers: set IP addresses of your DNS servers of choice, use commas to seperate multiple IP's.
- save
- disconnect network interface, reconnect
- check your new settings using nm-tool command.
Every time I have had the need to do this I have followed a similar procedure:
DNS-Servers.png
@Laurent85, I'm beginning to think this only works for you and I. Or maybe it's an LMDE thing.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Laurent85
Level 17
Level 17
Posts: 7081
Joined: Tue May 26, 2015 10:11 am

Re: [SOLVED] Permanent Change to DNS (Dynamic Nameserver)

Post by Laurent85 »

Hi @altair4, they all work in different ways as they meet different goals.

To be comprehensive about the different solutions exposed in this thread:
- Your setup adds 2 more DNS servers to nameserver list received from dhcp service. Name resolution queries are forwarded to ALL nameservers.
- Using Pjotr setup, depending on the configuration file used, "head" or "tail", some nameservers serve as backup nameservers if the primary ones are down.
- Using my setup, ONLY specified nameservers are used.
Image
User avatar
Pjotr
Level 24
Level 24
Posts: 20123
Joined: Mon Mar 07, 2011 10:18 am
Location: The Netherlands (Holland) 🇳🇱
Contact:

Re: [SOLVED] Permanent Change to DNS (Dynamic Nameserver)

Post by Pjotr »

Laurent85 wrote:- Using Pjotr setup, depending on the configuration file used, "head" or "tail", some nameservers serve as backup nameservers if the primary ones are down.
Yes.... To be fully exact: when added to "tail", a new name server is only a backup for the primary DNS of your internet service provider. When added to "head", a new name server is the primary DNS and the DNS of your internet service provider is the backup. :)
Tip: 10 things to do after installing Linux Mint 21.3 Virginia
Keep your Linux Mint healthy: Avoid these 10 fatal mistakes
Twitter: twitter.com/easylinuxtips
All in all, horse sense simply makes sense.
altair4
Level 20
Level 20
Posts: 11458
Joined: Tue Feb 03, 2009 10:27 am

Re: [SOLVED] Permanent Change to DNS (Dynamic Nameserver)

Post by altair4 »

Laurent85 wrote:Hi @altair4, they all work in different ways as they meet different goals.

To be comprehensive about the different solutions exposed in this thread:
- Your setup adds 2 more DNS servers to nameserver list received from dhcp service. Name resolution queries are forwarded to ALL nameservers.
- Using Pjotr setup, depending on the configuration file used, "head" or "tail", some nameservers serve as backup nameservers if the primary ones are down.
- Using my setup, ONLY specified nameservers are used.
altair@vxub1404:~$ nm-tool | grep DNS
DNS: 8.8.8.8
DNS: 8.8.4.4
OR:
altair@vxub1404:~$ nmcli device list | grep IP4.DNS
IP4.DNS[1]: 8.8.8.8
IP4.DNS[2]: 8.8.4.4
Doesn't this mean that my way and your way both replace the DNS servers with new ones and are the only ones used.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
Laurent85
Level 17
Level 17
Posts: 7081
Joined: Tue May 26, 2015 10:11 am

Re: [SOLVED] Permanent Change to DNS (Dynamic Nameserver)

Post by Laurent85 »

Doesn't this mean that my way and your way both replace the DNS servers with new ones and are the only ones used.
Oops, you are right. I did not look close enough. I tought "Method Automatic (DHCP)" was used. I did never considered what "Method Automatic (DHCP) addresses only" was used for. I note this one, thanks altair4 :)
Image
Locked

Return to “Beginner Questions”