How to change DNS on a minimal networking setup
I resolved this issue by adding the following to my network profiles under /etc/systemd/network/*.network
:
[DHCP]
UseDNS=false
By default, this is true, meaning DNS servers are pulled from the DHCP network connection. If I disable this feature, and input my own static DNS (ie OpenDNS), then I can ensure that I will only be using the DNS of my choosing.
Related videos on Youtube
modulitos
Updated on September 18, 2022Comments
-
modulitos over 1 year
How can I replace my DNS? I am not using a network manager, except for
systemd-networkd
andwpa_supplicant
for wireless, withwpa_cli
. I'm on Arch Linux, if it matters.Although I can add DNS to my config,
systemctl restart systemd-resolved
overwrites/etc/resolv.conf
(sym linked to/run/systemd/resolve/resolv.conf
), or a reboot, somehow add the default ISP DNS's to/etc/resolv.conf
. Does anyone know why, or how to resolve this issue to only use the DNS that I configured?When I edit
/etc/resolv.conf
to only containnameserver 208.67.222.222 nameserver 208.67.220.220
and run
systemctl restart systemd-resolved
or do a reboot, the default ISP DNS's are overwritten, andcat /etc/resolv.conf
is this:# This file is managed by systemd-resolved(8). Do not edit. # # Third party programs must not access this file directly, but # only through the symlink at /etc/resolv.conf. To manage # resolv.conf(5) in a different way, replace the symlink by a # static file or a different symlink. nameserver 75.75.75.75 nameserver 192.168.1.1 nameserver 208.67.222.222 # Too many DNS servers configured, the following entries may be ignored. nameserver 75.75.76.76 nameserver 208.67.220.220
As described under
man resolved.conf
, I ensured that I only have one config file,/etc/systemd/resolved.conf.d/resolv.conf
, containing# This file is part of systemd. # # systemd is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # See resolved.conf(5) for details [Resolve] DNS=208.67.222.222 208.67.220.220 #FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844 #LLMNR=yes
and no other files defining my DNS from all the configuration files under here:
/etc/systemd/resolved.conf /etc/systemd/resolved.conf.d/*.conf /run/systemd/resolved.conf.d/*.conf /usr/lib/systemd/resolved.conf.d/*.conf
I don't believe I am running any dhcpcd or netctl service either, and
systemctl | grep dhcpcd
, andsystemctl | grep netctl
returns nothing.