Resolv.conf

OpenBSD's name lookup relies on resolv.conf(5) to tell it which nameservers to query.

Change Default Nameserver

Suppose we want to use the nameserver 198.51.100.1 as our caching nameserver. If we are using DHCP and this differs from what we are given by the DHCP server, we may need to disable resolvd as follows:

# rcctl stop resolvd
# rcctl disable resolvd

Then, we can fill /etc/resolv.conf with our own values:

lookup file bind
nameserver 198.51.100.1

Use local caching nameserver

Suppose we want to run our own caching nameserver with unbound.

In that case, we edit /etc/resolv.conf:

lookup file bind
nameserver 127.0.0.1

Prefer IPv6

To get the resolver to choose IPv6 first, then fall back to IPv4:

family inet6 inet4

Put this in /home/znc/etc/resolv.conf to force ZNC to use IPv6 first.

Flush stale DNS records

If your records have changed, make sure to flush your old DNS cache before running host. How to do this depends on which nameservers you have specified in resolv.conf, whether you have setup resolvd, unwind, or unbound.

It's recommended to run your own local caching DNS server with unbound instead of using Google or the nameserver provided by your ISP. By running a local caching DNS server, you have more freedom to pick nameservers, which can help prevent censorship and privacy issues.

By default, host uses the nameservers you put in resolv.conf. Suppose this is present in /etc

nameserver 8.8.8.8
lookup file bind

resolv.conf tells your server to ask 8.8.8.8 (Google) for domain name lookup.

If you decide to use unbound, you will want to resolv.conf to point to localhost:

nameserver 127.0.0.1
lookup file bind

Then, if you have updated your DNS records, you can simply restart the nameserver to flush the cache of DNS records:

$ doas rcctl restart unbound

Then, run host again.