DNS caching resolver for home

Preface: the fortigate I am using at home sucks at DNS – in fact it sucks at many things when you are used to a FritzBox – but I am stubborn and I will do this because I work with fortigates and want the learning experience. (and because I am stubborn)

somehow the big models can all do forward DNS services but the FortiWifi40C somehow can’t even act as a DNS gateway / proxy without bringing the internet experience to a grinding halt here.
(I run a small network, about 5 devices and 4 mobiles and if I can feel it I don’t want to know what a small office will experience…)
But: I have this Raspberry that receives audio via zeroconf and is connected to the network and to my amplifier.
Why not have it act as a caching DNS resolver, too?

Easy with raspian:
# apt-get install unbound
add interfaces to the config and point it to your ISPs DNS server and it should roll.
But we want the full bells and whistles like IPv6 and DNSSEC so let’s do this the proper way:

install a root dns list:
# wget ftp://FTP.INTERNIC.NET/domain/named.cache -O /etc/unbound/root.hints

now edit config and call this file and enable interfaces, IPv6 and TCP as well as an ACL so we won’t turn into an open relay accidentially (the fortigate should prevent that but you never know…)
also disable remote control for now:

# The following line will configure unbound to perform cryptographic
# DNSSEC validation using the root trust anchor.
auto-trust-anchor-file: "/var/lib/unbound/root.key"

#root dns list
root-hints: "/etc/unbound/root.hints"

#listen on all interfaces
interface: ::0

# access-control for local subnet
access-control: allow
access-control: allow
access-control: allow
access-control: 2001:XXXX:XXXX::/32 allow
access-control: 2001:DB8::/64 allow
access-control: FE80::/8 allow
verbosity: 1

control-enable: no

#forward anything else to xs4all dns server
name: "."
forward-addr: 2001:888:0:6::66
forward-addr: 2001:888:0:9::99

this already works!

test by using dig with IPv4 and IPv6 address, then add the raspberry to your DHCP server and enjoy millisecond resolve times :)

tweaking for healthy memory consumption and adding forward and reverse zone for my LAN is next:
(thanks to https://www.the-hawkes.de/unbound-dns-on-raspberry-pi.html )

#my domain name and the available hosts
private-domain: "home."
include: /etc/unbound/forward.conf
include: /etc/unbound/reverse.conf

The forward lookup file (name -> ip)

local-zone: "home." static

local-data: "speedport.home. IN A"
local-data: "kasekuchen.home. IN A"
local-data: "raspberryone.home. IN A"
local-data: "rbone.home. IN A"
local-data: "rb1.home. IN A"
local-data: "htpc.home. IN A"
local-data: "wlan.home. IN A"

Reverse lookup (ip -> name)

local-data-ptr: " speedport.home."
local-data-ptr: " kasekuchen.home."
local-data-ptr: " raspberryone.home."
local-data-ptr: " raspberrytwo.home."
local-data-ptr: " htpc.home."
local-data-ptr: " wlan.home."

and verifying mem and DNSSEC functionality:
see here:
and here: