DNS on Fedora/Red Hat

Since Fedora 33 the way DNS is resolved has changed. It can be that you have a DNS server in your network, which is not used.

For example you have some local servers, say: mail.local or fileserver.local. You have a DNS server in your network which resolves those names to an IP address. This particular set-up might not work properly any longer in the latest Fedora/Red Hat releases.

To fix this you can edit the following file: /etc/systemd/resolved.conf

#  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.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the resolved.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.

[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4>
# Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
# Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
DNS=192.168.x.x
#FallbackDNS=
Domains=local
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=resolve
#Cache=yes
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no

This way you can set globally that you want to use that DNS server to resolve .local addresses. After making this change you can reboot your machine, or restart the following service:

sudo systemctl restart systemd-resolved.service

Another way to do it, which might be even better is by not modifying the resolved.conf file, but make use of drop-ins.
In this case you put a configuration file in the following directory: /etc/systemd/resolved.conf.d
If this directory does not exist you can create it.

Now create a file called, for example, local.conf in this directory with the following content:

[Resolve]
DNS=192.168.x.x
Domains=local

To activate these changes, either reboot or restart the systemd-resolved service as mentioned above.


Posted

in

by

Tags: