{"id":499,"date":"2017-04-18T11:01:39","date_gmt":"2017-04-18T09:01:39","guid":{"rendered":"http:\/\/itso.dk\/?p=499"},"modified":"2017-04-19T12:03:52","modified_gmt":"2017-04-19T10:03:52","slug":"freebsd-dns-server-unbound","status":"publish","type":"post","link":"https:\/\/blog.itso.dk\/?p=499","title":{"rendered":"FreeBSD 11  Unbound DNS server"},"content":{"rendered":"<p>In FreeBSD, there is a built-in DNS server called Unbound.<\/p>\n<p>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.<\/p>\n<p>All commands run as root, or a user with sudo\/admin rights.<br \/>\nMy network router\/dns\/gateway: 192.168.1.1<br \/>\nMy new DNS server: 192.168.1.250<br \/>\nMy NIC on new DNS server: vr0<\/p>\n<pre>sysrc ifconfig_vr0=\"inet 192.168.1.250 netmask 255.255.255.0\" \u00a0\r\nsysrc ifconfig_vr0=\"defaultrouter 192.168.1.1\" \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\r\necho \"nameserver 192.168.1.1\" &gt; \/etc\/resolv.conf \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0   \r\necho \"nameserver 8.8.8.8\" &gt;&gt; \/etc\/resolv.conf \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\r\nservice netif restart \u00a0 \u00a0 \u00a0 \u00a0 \u00a0                               \r\n\/etc\/rc.d\/routing restart<\/pre>\n<p>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.<\/p>\n<pre>pkg install unbound\r\n\r\nsysrc unbound_enable=\"YES\"\r\n\r\nservice unbound start<\/pre>\n<p>Default setting unbound only works for localhost, we need to change that setting:<\/p>\n<pre>cat &lt;&lt;EOF&gt; \/usr\/local\/etc\/unbound\/unbound.conf\r\n\r\nserver:\r\n\u00a0 \u00a0 \u00a0 username: unbound\r\n\u00a0 \u00a0 \u00a0 directory: \/usr\/local\/etc\/unbound\r\n\u00a0 \u00a0 \u00a0 chroot: \/usr\/local\/etc\/unbound\r\n\u00a0 \u00a0 \u00a0 auto-trust-anchor-file: \/usr\/local\/etc\/unbound\/root.key\r\n\u00a0 \u00a0 \u00a0 interface: 0.0.0.0\r\n\u00a0 \u00a0 \u00a0 access-control: 192.168.1.0\/24 allow\r\nforward-zone:\r\n\u00a0 \u00a0 \u00a0 name: .\r\n\u00a0 \u00a0 \u00a0 forward-addr: 192.168.1.1\r\n\u00a0 \u00a0 \u00a0 forward-addr: 8.8.8.8\r\nEOF<\/pre>\n<p>Now lets set where our DNS server actually gets its DNS quires from:<\/p>\n<pre>service unbound restart<\/pre>\n<p>Now go point you device to your new DNS server!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &#8230;<\/p>\n<p><a href=\"https:\/\/blog.itso.dk\/?p=499\" class=\"more-link\">Continue reading &lsquo;FreeBSD 11  Unbound DNS server&rsquo; &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":245,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-499","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-freebsd"],"_links":{"self":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts\/499","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=499"}],"version-history":[{"count":15,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts\/499\/revisions"}],"predecessor-version":[{"id":513,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/posts\/499\/revisions\/513"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=\/wp\/v2\/media\/245"}],"wp:attachment":[{"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.itso.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}