I'm working on Fedora 31. I need to override DNS resolution for one domain. Using /etc/hosts I would add:

172.16.2.1 example.com 172.16.2.1 

I'm not sure what I am supposed to do nowadays with Systemd. I can't find a discussion in the Fedora System Administration Guide. The internet is returning noise and fodder.

How do we override DNS resolution for one name on Fedora 31 with Systemd?


Here is /etc/resolv.conf:

$ cat /etc/nsswitch.conf | grep -v '#' | sed -r '/^\s*$/d' passwd: sss files systemd shadow: files sss group: sss files systemd hosts: files dns myhostname bootparams: files ethers: files netmasks: files networks: files protocols: files rpc: files services: files sss netgroup: sss publickey: files automount: files sss aliases: files 
3

1 Answer

Yes, modifying /etc/hosts is the proper way to override standard DNS.

It will not work if you are using DNS over HTTPS (DOH).

Some operating systems and browsers will require their internal DNS cahces to be flushed for immediate changes in name resolution.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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