FreeBSD 11 Unbound DNS server

In FreeBSD, there is a built-in DNS server called Unbound.

So why would run a local DNS server? I am in a region where internet traffic is still a bit expensive, that also implies slow, and high response times. To speed that a up a little, you can use own DNS server. It will speed up because for every homepage you visit, there will be several hooks to other domains: commercials, site components, and links to other sites. These, will now all be cached locally on your new DNS server. In my case I use an old PC-Engine Alix board for my home DNS server, but you can use almost everything, Raspberry Pi, old laptop/desktop and others. As long as it runs FreeBSD.

All commands run as root, or a user with sudo/admin rights.
My network router/dns/gateway:
My new DNS server:
My NIC on new DNS server: vr0

sysrc ifconfig_vr0="inet netmask"  
sysrc ifconfig_vr0="defaultrouter"                
echo "nameserver" > /etc/resolv.conf               
echo "nameserver" >> /etc/resolv.conf                  
service netif restart                                         
/etc/rc.d/routing restart

Now lets install the unbound server. There is a built-in in FreeBSD callen local_unbound, but it is build for local only. While you can tweak it to work as LAN DNS, it is adviced to use the package unbound instead.

pkg install unbound

sysrc unbound_enable="YES"

service unbound start

Default setting unbound only works for localhost, we need to change that setting:

cat <<EOF> /usr/local/etc/unbound/unbound.conf

      username: unbound
      directory: /usr/local/etc/unbound
      chroot: /usr/local/etc/unbound
      auto-trust-anchor-file: /usr/local/etc/unbound/root.key
      access-control: allow
      name: .

Now lets set where our DNS server actually gets its DNS quires from:

service unbound restart

Now go point you device to your new DNS server!