# Custom DNS

Per default, the DNS settings get set automatically and there is no way to change them (v4.0.5.18). This guide shows you how to replace connman's DNS with dnsmasq and setting your own DNS config.

# Stop connman from managing DNS

<p class="callout warning">If you don't have any DNS configured in /etc/resolv.conf anymore, you can't resolv any domains on the internet. It's smart to install a replacement for connman's DNS in advance. Otherwise you can temporarily solve that by executing echo "9.9.9.9" | devel-su tee /etc/resolv.conf</p>

You need to add the `--nodnsproxy` proxy flag to connmand. This can be done by runing `devel-su systemctl edit connman` and pasting this into there:

```html
[Service]
RuntimeDirectory=connman
```

Afterwards run `devel-su systemctl restart connman`.

# Use dnsmasq for DNS

<p class="callout info">As the name already implies, dnsmasq is not a full-fledged DNS server. If you want a real, recursive DNS resolver, consider using unbound instead.</p>

##### <span style="text-decoration: underline;">Install dnsmasq</span>  


dnsmasq is available on [SailfishOS chum.](https://github.com/sailfishos-chum/main) You 1st need to add the 3rd-party-repo, afterwards running `devel-su pkcon refresh && pkcon install dnsmasq` will install it.

##### <span style="text-decoration: underline;">Disable your current DNS handler</span>

On a fresh installation, DNS is handled by [connman](https://wiki.archlinux.org/title/ConnMan). You can remove it with [these instructions](https://sailfishos.wiki/books/network/page/stop-connman-from-managing-dns "Stop connman from managing DNS").

##### <span style="text-decoration: underline;">Permanently run dnsmasq on boot</span>

ExecuteÂ `devel-su systemctl enable --now dnsmasq` to enable it permanently &amp; start it now.

##### <span style="text-decoration: underline;">Configure dnsmasq</span>

dnsmasq's configuration lies under `/etc/dnsmasq.conf`. You can get more information about its config options from dnsmasq's [manpage](https://man.archlinux.org/man/dnsmasq.8) and [ArchWiki](https://wiki.archlinux.org/title/Dnsmasq).

# Install & configure unbound DNS server

Unbound is a full-fledge recursive DNS resolver. You should consider to not fetch from the root servers but [forward your requests to another Server via DoT](https://wiki.archlinux.org/title/Unbound#Forwarding_using_DNS_over_TLS). Bind unbound to 127.0.0.1 to avoid access from outside.

More information can be found in [ArchWiki](https://wiki.archlinux.org/title/Unbound).