DNS - Configure a Linux system to use DNS servers

by
Jeremy Canfield |
Updated: October 02 2021
| DNS articles
On a Red Hat distribution (CentOS, Fedora, Red Hat) running at Red Hat version 8, the nmcli connection show command is used get the name of the network interface you want to modify.
nmcli connection show
. . .
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0
The nmcli connection show command can then be used to display the current DNS setting of the network interface.
~]# nmcli connection show ens192 | grep dns
connection.mdns: -1 (default)
ipv4.dns: 192.168.0.6,8.8.8.8
ipv4.dns-search: --
ipv4.dns-options: --
ipv4.dns-priority: 0
ipv4.ignore-auto-dns: no
ipv6.dns: --
ipv6.dns-search: --
ipv6.dns-options: --
ipv6.dns-priority: 0
ipv6.ignore-auto-dns: no
The nmcli connection modify command can be used to modify the DNS servers for the network interface.
nmcli connection modify eth0 ipv4.dns "10.124.141.51,10.112.42.10"
nmcli device reapply eth0
The resolvectl command can then be used to show the DNS servers. However, notice that "Current DNS Server" is not included in the output.
~]# resolvectl
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (ens192)
Current Scopes: DNS LLMNR/IPv4
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 10.124.141.51 10.112.42.10
Use the nslookup command
~]# nslookup foo.example.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: foo.example.com
Address: 192.168.0.12
Now "Current DNS Server" should be included in the output of the resolvectl command.
~]# resolvectl
Global
Protocols: LLMNR=resolve -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (ens192)
Current Scopes: DNS LLMNR/IPv4
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 10.124.141.51
DNS Servers: 10.124.141.51 10.112.42.10
Did you find this article helpful?
If so, consider buying me a coffee over at