Cannot figure out DNS config

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
Azhar
Posts: 28
Joined: 2016-10-28 18:28

Cannot figure out DNS config

#1 Post 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

Aki
Global Moderator
Global Moderator
Posts: 4259
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 124 times
Been thanked: 576 times

Re: Cannot figure out DNS config

#2 Post 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.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Aki
Global Moderator
Global Moderator
Posts: 4259
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 124 times
Been thanked: 576 times

Re: Cannot figure out DNS config

#3 Post by Aki »

Hello,
Did you sorted it out ?
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
Uptorn
Posts: 455
Joined: 2022-01-22 01:07
Has thanked: 345 times
Been thanked: 122 times

Re: Cannot figure out DNS config

#4 Post 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.

Post Reply