cross-posted from: https://reddthat.com/post/221970

Hello friends! I kept searching how to do this but had trouble finding the information, but now that I have found out how to do it, I thought I would post it here in case others are looking for it.

Problem we are solving

You want to set the DNS server’s address for your network connection. Typically, this is handled by DHCP server, but if you have enabled EnableNetworkConfiguration in the iwd config, then iwd is the one deciding which is your DNS server, and relays that information to your resolver, which in most cases is systemd-resolved but sometimes openresolv.

This is also the same as setting the standalone USE flag

How to Set DNS

Go to /var/lib/iwd folder, and look for the file that holds NETWORK_NAME.psk (where NETWORK_NAME is the SSID of the network you are connected to).

In this file, you will find some text pre-written. If it does not exist already, create a [IPv4] section. Under this section, add the line DNS=192.168.1.1 or whatever you wanted the DNS server to be. Your file should end up having a section that looks like this:

[IPv4]
DNS=192.168.1.1

restart iwd server and now you should be connecting to the right DNS server!