Page 1 of 1

Cannot figure out DNS config

Posted: 2025-01-19 10:03
by Azhar
My laptop is connected to home DSL which is configured with DHCP. From what i understand, DNS is also configured through DHCP.
I have a debian 12 system, in which i changed the resolv.conf to following

Code: Select all

# 
Generated by NetworkManager
nameserver 185.228.168.9
nameserver 8.8.8.8
nameserver 9.9.9.9
but when i run the following command it shows me DNS set by my DSL router

Code: Select all

( nmcli dev list || nmcli dev show ) 2>/dev/null | grep DNS

IP4.DNS[1]:                             192.168.10.1
IP4.DNS[2]:                             192.168.25.1
My question is, are the two IP4 DNS shown, are used by my system or network. If it is of my system, then why isn't it using DNS set in resolv.conf?


Edit

I got the following command through forums, i am not sure how it works or what it show

Code: Select all

( nmcli dev list || nmcli dev show ) 2>/dev/null | grep DNS

Re: Cannot figure out DNS config

Posted: 2025-01-19 10:51
by Aki
Hello,
Azhar wrote: 2025-01-19 10:03 I have a debian 12 system, in which i changed the resolv.conf to following

Code: Select all

#  Generated by NetworkManager
nameserver 185.228.168.9
nameserver 8.8.8.8
nameserver 9.9.9.9
but when i run the following command it shows me DNS set by my DSL router

Code: Select all

( nmcli dev list || nmcli dev show ) 2>/dev/null | grep DNS
IP4.DNS[1]:                             192.168.10.1
IP4.DNS[2]:                             192.168.25.1
My question is, are the two IP4 DNS shown, are used by my system or network. If it is of my system, then why isn't it using DNS set in resolv.conf?
Edit
I got the following command through forums, i am not sure how it works or what it show

Code: Select all

( nmcli dev list || nmcli dev show ) 2>/dev/null | grep DNS
The first line of /etc/resolv.conf shows the comment:

Code: Select all

#  Generated by NetworkManager
The NewtworkManager program will replace the contents of /etc/resolve.conf with the DNS server IP address received from the DHCP lease when it is used to configure the network using the DHCP service (this is the most common situation for home installations). So any IP manually added to /etc/resolv.conf beforehand can be removed after network configuration in this scenario.

You may investigate the output of the nmcli dev show command this way:

Code: Select all

script log.txt
getent ahosts 
PAGER= nmcli device show
exit
The file log.txt will contain the output of previous commands.

Here the manual page for nmcli: Hope this helps.

Re: Cannot figure out DNS config

Posted: 2025-02-02 09:50
by Aki
Hello,
Did you sorted it out ?

Re: Cannot figure out DNS config

Posted: 2025-02-05 03:41
by Uptorn
The question of what program controls resolv.conf is a fun (as in ripping your hair out) rabbit hole explore.

It took me way too long to arrive at the conclusion that the most direct and DE-independent way to set one's preferred DNS resolvers is to do so through isc-dhcp-client while also making certain to disable competing programs that would otherwise attempt to overwrite resolv.conf (such as Network Manager, which you have installed).

First, I prevent Network Manager from interfering by editing /etc/NetworkManager/NetworkManager.conf

Code: Select all

[main]
dns=none
And then apply the changes

Code: Select all

sudo systemctl restart NetworkManager
Then I insert my preferred resolvers to /etc/dhcp/dhclient.conf

Code: Select all

supersede domain-name-servers 9.9.9.9;
*If you want to override the DNS servers provided by DHCP entirely and force the system to use the ones you provide, use the supersede entry:
supersede domain-name-servers
Then renegotiate DHCP

Code: Select all

sudo dhclient -r
sudo dhclient
This yields reliable, unchanging resolver entries at /etc/resolv.conf

I think a lot of old hats assume this is just obvious knowledge. But people that haven't been doing the whole *nix thing since the 90s are left to trial-by-fire.

Re: Cannot figure out DNS config

Posted: 2025-02-05 18:36
by Aki
Hello,
Uptorn wrote: 2025-02-05 03:41 The question of what program controls resolv.conf is a fun (as in ripping your hair out) rabbit hole explore.
:D
Uptorn wrote: 2025-02-05 03:41 [..] the most direct and DE-independent way to set one's preferred DNS resolvers is to do so through isc-dhcp-client while also making certain to disable competing programs that would otherwise attempt to overwrite resolv.conf (such as Network Manager, which you have installed).
Configuring the DNS address via DHCP is only one of the use cases, and the package named isc-dhcp-client is not the only DHCP client in Debian.

So for the majority of Debian users, it is probably best to stick with the default Debian configuration by installed packages.

My 2 cents.

Re: Cannot figure out DNS config

Posted: 2025-02-05 21:46
by Uptorn
I needed something that was consistent across headless systems as well as those with various desktop environments. isc-dhcp-client is the one I'd found already installed and so I treat it as Debian's 'default'.