NetworkManager and custom DNS

Hi All,

I’m having difficulties setting up a custom DNS that actually works with NetworkManager.

I have followed the instructions on here: https://en.opensuse.org/SDB:Configure_DNS

In short:

  1. I have set the method to “Manual”
  2. specified that IPv6 is required
  3. entered the addresses for the custom DNS
  4. entered rc-manager=file into NetworkManager.conf

Now, when I restart the connection Method is back on “Automatic”, and a quick check online shows that I am using the ISP’s default DNS instead of the new ones. I have also foolishly tried editing resolv.conf, before I realised that gets overwritten every time NetworkManager starts. What am I getting wrong?

Also, I understand that even if I manage to make it work, this would only be valid for a single connection. Is there a way to set my DNS for every connection?

Show what you did, not describe.

Show the actual connection definition from the /etc/NetworkManager/system-connections/. Show /etc/resolv.conf. Show how exactly you

No. The simplest way is to not try to outsmart NetworkManager but leave it at default settings which will use netconfig and configure netconfig to use static addresses and ignore information from NetworkManager.

The .nmconnection contains the right values:

[connection]
id=WiFi
uuid=-----EDITED------
type=wifi
metered=2
zone=home

[wifi]
mode=infrastructure
ssid=-----EDITED------

[wifi-security]
key-mgmt=-----EDITED------
psk=-----EDITED------

[ipv4]
dns=----CUSTOM ipv4 DNS IPs----;
method=auto

[ipv6]
addr-gen-mode=stable-privacy
dns=----CUSTOM ipv6 DNS IPs----;
may-fail=false
method=auto

[proxy]

and here’s resolv.conf

# Generated by NetworkManager
search lan
nameserver ----CUSTOM ipv4 DNS IP 1----
nameserver ----CUSTOM ipv4 DNS IP 2----
nameserver 192.168.00.10
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver ----CUSTOM ipv6 DNS IP 1----
nameserver ----CUSTOM ipv6 DNS IP 2----

and as for restarting the connection I mean switching the wifi off and on again

dns does not replace information from DHCP, it complements it. If you want to ignore DHCP DNS servers, you need to set

ipv4.ignore-auto-dns

See man nm-settings.

That’s why I initially set the method in the connection to “Manual”.

But for some reason the “Manual” option is not persistent, and as soon as the connection is restarted it turns back on “Automatic”.
How can I set it to be persistent? nmconnection is a read-only file, and it gets rewritten at every connection start as well

@madsplinter Hi, I just use the network manager and create profiles for all the different connections I need, ip’s, dns, dhcp etc?

I have done that, but for some reason the DNS choice gets overridden.
@arvidjaar noted above that for my NetworkManager setup to work as intended I should have in the configuration ipv4.ignore-auto-dns, which I suppose is the same to set the method to “Manual”, but this reverts to auto every time

I have no idea what you were doing. You did not even name the frontend you used to configure NetworkManager so set method to “Manual” does not really mean anything.

Show the initial connection profile. Do your configuration changes. Before doing anything else show this connection profile again. Did it change? Now do something that results in “DNS choice gets overridden”. Show the connection profile again. Are there any changes?

But I ask myself, if you always want to use the same DNS servers anyway, why do you insist on NetworkManager managing your /etc/resolv.conf to start with? Why not tell NetworkManager to not touch /etc/resolv.conf and simply enter there the DNS servers you need “for every connection”?

I am using kNetworkManager, and these are the options I have:

If I set method to Manual, the last line in ipv4 and ipv6 of nmconnection turns to, well, manual, e.g.:

[ipv6]
addr-gen-mode=stable-privacy
dns=----CUSTOM ipv6 DNS IPs----;
may-fail=false
method=manual

once I restart the connection it changes back to auto, i.e.

[ipv6]
addr-gen-mode=stable-privacy
dns=----CUSTOM ipv6 DNS IPs----;
may-fail=false
method=auto

That’s what I am asking for. Could you please suggest how to achieve that with kNetworkManager?

Post:
ls -al /etc/resolv.conf

-rw-r--r-- 1 root root 132 Jul 13 19:26 /etc/resolv.conf

I have no idea about kNetworkManager. You already mentioned NetworkManager.conf, so I assumed you were aware of it.

man NetworkManager.conf and search for “DNS processing mode”.

dns=none

I still do not understand what “restart the connection” means.

As I wrote above:

Screenshot

You mean you toggle a switch on the hardware?

yes, precisely

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.