Thursday, November 17, 2016

Local DNS zone with unbound

If you have OpenWRT based router you can quite easily set you local DNS and make your life easier. I did.

In config file /etc/config/resolver add section config resolver 'unbound_includes' with line
list include_path '/etc/unbound/local.conf'

It shall look like this:

config resolver 'unbound_includes'
 list include_path '/etc/unbound/local.conf'

Create the file which was included, hence /etc/unbound/local.conf
Below is my setting, you might noticed I'm lame and use several A records instead of CNAME, well actually unbound doesn't support CNAME record.
I created one domain .local and set there few common devices which have global role (central heating, printer, network storage). I also created subdomain .livingroom.local where are devices in living room. I plan other subdomains, because I would like to place several sensors all around the house.

server:
local-zone: 'local.' static
local-data: 'judo.local. IN A 10.0.0.37'
local-data: 'nas.local. IN A 10.0.0.33'
local-data: 'nsa320.local. IN A 10.0.0.33'
local-data: 'brother.local. IN A 10.0.0.39'
local-data: 'printer.local. IN A 10.0.0.39'
local-data: 'heating.local. IN A 10.0.0.42'
local-data: 'turris.local. IN A 10.0.0.1'

local-zone: 'livingroom.local.' static
local-data: 'yun.livingroom.local. IN A 10.0.0.43'
local-data: 'evolve.livingroom.local. IN A 10.0.0.38'
local-data: 'tv.livingroom.local. IN A 10.0.0.38'
local-data: 'dvb-t.livingroom.local. IN A 10.0.0.38'
local-data: 'switch.livingroom.local. IN A 10.0.0.34'
local-data: 'xbox360.livingroom.local. IN A 10.0.0.41'
local-data: 'nec.livingroom.local. IN A 10.0.0.40'
local-data: 'monitor.livingroom.local. IN A 10.0.0.40'
local-data: 'display.livingroom.local. IN A 10.0.0.40'
local-data: 'yamaha.livingroom.local. IN A 10.0.0.36'
local-data: 'av-reciever.livingroom.local. IN A 10.0.0.36'
local-data: 'reciever.livingroom.local. IN A 10.0.0.36'

Now restart unbound service
/etc/init.d/unbound restart
and enjoy

No comments: