11

I'm trying to modify NetworkManager's default DNS settings so that whenever I add a new connection it uses 127.0.0.1 instead of the default DNS for that connection. I still would like to be able to modify the DNS for each individual connections afterwards however.

I set up DNSCrypt recently, and it worked great on most networks. However, some networks that I use require that I use their DNS server instead of DNSCrypt, meaning that I cannot simply set the default nameserver on resolv.conf to 127.0.0.1. I found that NetworkManager/nmcli still did a good job of using DNSCrypt when I changed some of the networks to use 127.0.0.1. However, it would be very nice if each new connection had this config by default:

/etc/NetworkManager/system-connections/connection.conf

[ipv4]
dns=127.0.0.1;
ignore-auto-dns=true
method=auto

In my research I found this in the NetworkConfig.conf manpage:

Specify default values for connections.

Example:

    [connection]
    ipv6.ip6-privacy=0

However, there are only a few supported properties, and trying this did not work:

[connection]
ipv4.method=auto
ipv4.dns=127.0.0.1;
ipv4.ignore-auto-dns=true

I was wondering if there were any know workarounds to this issue, either using NetworkManager or something different.

3
  • Have you ever found a solution to this? Sep 30, 2017 at 20:48
  • 1
    Unfortunately no, I ended up switching to systemd-networkd, but I have yet to implement dnscrypt Sep 30, 2017 at 20:54
  • 2
    I researched based on your comment and, since NetworkManager now uses systemd-networkd (at least on Ubuntu 17.04), the only thing I had to was create the /etc/systemd/network/ files and restart both services. I continue using NetworkManager and systemd takes care of the DNS (tested with systemd-resolve --status). Sep 30, 2017 at 22:00

1 Answer 1

0

I am not allowed to comment yet to probe for further information to ensure that I can accurately solve your issue, however, I don't believe that I need too based on what I read in the documentation and from experience using other software packages constructed in this manner. While I don't have the ability to test this out right now to make absolutely sure that it is accurate from what I gleaned, you can put your default values into a file under /usr/lib/NetworkManager/system-connections and they take less weight than the versions in /etc/NetworkManager/system-connections. Then in the etc tree, you can just override what you want changed.

Maybe try putting your initial solution into the /usr/lib tree named the same as the file you have under the etc tree:

[ipv4]
dns-priority=100
dns=172.20.21.1
ignore-auto-dns=true

Generally speaking, files under /usr/lib/* are meant to be what the package maintainer wants you to use (or a sane default) and /etc/ is for what the sysadmin (you) wants to use, so I don't see why it doesn't apply here as well.

Should this solution not fix the issue, I also propose that you create some sort of transient config for those "other networks" that you have to use from time to time like the VPN configurations do. That way you only need to change your settings when you need them instead of trying to create a happy-medium config that will fit all... Doing so will likely reduce potential issues with routing from attempted traversal of invalid paths.

Lastly, in your question, you stated that you tried to place ipv4.xxxx under [connection]. You have to place those statements in their proper stanza under [ipv4].

You seem to know what's up, so maybe the bit about /usr vs /etc was what is eluding you. (the same is true for files in /var too btw.) Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.