DrKK's Guide on DNS -- What It Is, and How to Install Your Own DNS Server on FreeNAS/BSD

Status
Not open for further replies.

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Would you like to know how to install your own DNS server in your FreeNAS appliance? Then, you may find that my just-published video on YouTube should explain the whole thing to you in a way you can understand. Below is my recommended configuration file for the DNS server that I recommend:


DrKK's recommend unbound.conf file for small installations:

Code:
## DrKK's Simple recursive caching DNS pool
##
## Conservative system resource usage for ZFS/FreeNAS environment.
## ***NOT*** appropriate for a heavily loaded environment!
##
## This uses settings that are pretty minimal---i.e., I expect
## this keeps the memory footprint low, while generally offering
## full performance for the typical home/small business user.  These
## settings would be ridiculous for a large enterprise.
#
## DrKK can be found on the #FreeNAS irc channel, or in the forums
## at http://forums.freenas.org/
#
## The DNS forwarders listed below work well for me.  DO YOUR RESEARCH.
#
server:
  interface: 0.0.0.0
# The following line assumes your LAN is on the usual 192.168.x.x network.  Change
# this setting if necessary.
  access-control: 192.168.0.0/16 allow
  verbosity: 1
  statistics-interval: 3600
  statistics-cumulative: yes
#  outgoing-range: 800
  outgoing-range: 256
  num-threads: 1
  msg-cache-size: 1m
  msg-cache-slabs: 1
  num-queries-per-thread: 128
  rrset-cache-size: 2m
  rrset-cache-slabs: 1
  infra-cache-numhosts: 16
  infra-cache-slabs: 1
  do-ip4: yes
  do-ip6: no
  do-udp: yes
  do-tcp: no
  logfile: "unbound.log"
  use-syslog: no
  log-time-ascii: yes
  private-address: 10.0.0.0/8
  private-address: 172.16.0.0/12
  private-address: 192.168.0.0/16
  private-address: 169.254.0.0/16
  do-not-query-localhost: yes
  log-queries: no
  identity: "unbound DNS running on FreeNAS"
  target-fetch-policy: "0 0 0 0 0"
  prefetch: yes
  cache-max-ttl: 604800
  module-config: "iterator"


forward-zone:
## This is a good set of resolvers for the eastern US.  Recommend
## that you investigate the best servers for your location.  I recommend
## Steve Gibson's DNSBench: https://www.grc.com/dns/benchmark.htm
  name: "."
  forward-addr: 199.45.32.40
  forward-addr: 63.218.44.186
  forward-addr: 216.52.126.1
  forward-addr: 8.8.8.8


# OPTIONAL REMOTE CONTROL SETTINGS (comment out if desired)
# You must run unbound-control-setup before unbound-control can be used.
remote-control:
  control-enable: yes
  control-interface: 0.0.0.0
 
Last edited:

Nishanth

Cadet
Joined
Nov 23, 2014
Messages
6
Thanks for this tutorial ,, You saved my day so much for understating the DNS :)
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Thanks for this tutorial ,, You saved my day so much for understating the DNS :)
Awesome. This is, by far, my least popular video/tutorial! lol.
 

JJT211

Patron
Joined
Jul 4, 2014
Messages
323
Whats are the advantages of running your own DNS server? I googled a bit and everything I've found only mentions advantages if you're hosting website. What about the average user? Speed? If so, what's the tradeoff on server load?
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Great video, thanks for passing on some of the knowledge.

Will have a go setting this up at some point, as I've been meaning to have a play with DNS so I can just type some names into my browser, rather than IP addresses, for the devices on my network.

Saving a few milliseconds resolving external web addresses will be a bonus :D
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Whats are the advantages of running your own DNS server? I googled a bit and everything I've found only mentions advantages if you're hosting website. What about the average user? Speed? If so, what's the tradeoff on server load?
These are excellent questions sir. Allow me to answer:

There are--for most home users--no "huge" advantages to running your own DNS server. However, running your own DNS server has a number of small to medium advantages:

  • You have a large, local, DNS cache. Meaning that somewhere around 50-80% of your DNS queries will resolve in just a couple milliseconds on your LAN. Typically, when you recurse out the WAN, you can expect your queries to take more like 25 ms (if you're very, very lucky) to about 250ms. Those little bits can add up, in certain cases. In real terms, the "speed up" is enough to notice if you're trying to notice it, but not (usually) enough to notice if you're not paying attention.
  • The above mentioned cache is *SHARED* presumably, amongst all your LAN clients. In other words, if I go to download.freenas.org on computer A in my house, let's say that my local DNS server resolves download.freenas.org for computer A, and (presumably) caches it. Now, when someone on computer B (who is using the same local DNS server) goes to download.freenas.org, *HE* will share in the bounty of the cache, and will have his DNS for that host resolved in 1 ms. If you had the "normal" setup, computer B will have to look up download.freenas.org on the WAN just as computer A did. So the speed benefits talked about by #1 are shared in #2.
  • DNS constitutes a lot of internet traffic. Much of it (as you see by the first couple bullets) is redundant, you can serve it yourself on your local network.
  • It is very educational; after all DNS is a fundamental protocol/service of the modern internet.
  • Watching the stats on the DNS server yields some surprising/shocking realizations of things.
...and the most important reason of all:
  • I think DNS is awesome, and if you don't, you're a bad person. :)

I hope that answered some of your questions?
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Also you asked about load.

An "unbound" DNS server, like the one I show in the tutorial, will be almost immeasurably small load in a home environment. It'll be less load, for example, than your syslogd or your nmbd.
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Great video, thanks for passing on some of the knowledge.

Will have a go setting this up at some point, as I've been meaning to have a play with DNS so I can just type some names into my browser, rather than IP addresses, for the devices on my network.

Saving a few milliseconds resolving external web addresses will be a bonus :D
you will need to set up "local stub zones" to do that. It's one unit beyond what I show in the video. In the video, I show how to set up a purely recursive caching DNS server. You will need one that also replies authoritatively or quasi-authoritatively to local domain names. So that's one more unit of difficulty, but still manageable.
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
This really is a fantastic guide and it was setup in no time at all - thanks!

I also did a little light DNS reading today to try and understand how I can alter the config to resolve my local devices by name rather than IP address.

You mentioned "local stub zones" but the unbound documentation and www.calomel.org talked about "local zones" but I'm not sure these are the same thing?

I had a crack at adding some code, but couldn't get the unbound service to start after i'd fiddled about so was looking for some more help please!

This is what I added to the bottom of the unbound.conf file (but it's all #ed out at the minute as it doesn't work):

Code:
# locally served zones can be configured for the machines on the LAN.

# local-zone: "localhost." static
# local-data: "localhost. 10800 IN NS localhost."
# local-data: "localhost. 10800 IN SOA localhost. nobody.invalid. 1 3600 1200 604800 10800"
# local-data: "localhost. 10800 IN A 127.0.0.1"
# local-data: "localhost. 10800 IN AAA ::1"

#  local-data: "apeserver.localhost IN A 192.168.168.50"
#  local-data: "freenas1.localhost IN A 192.168.168.65"
#  local-data: "freenas2.localhost IN A 192.168.168.165"
#  local-data: "owncloud.localhost IN A 192.168.168.69"
   
#  local-data-ptr: "192.168.168.50 apeserver.localhost"
#  local-data-ptr: "192.168.168.65 freenas1.localhost"
#  local-data-ptr: "192.168.168.165 freenas2.localhost"
#  local-data-ptr: "192.168.168.69 owncloud.localhost"


All I'm aiming to achieve is to be able to type "freenas1" in my browser address bar instead of "192.168.168.65"

Any clues or pointers would be much appreciated :D
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
OH, in that case, you should only have to do this:
https://www.unbound.net/pipermail/unbound-users/2011-March/001733.html

make sure the "local" directive is in your /etc/resolv.conf, as shown in this link.

you probably don't need/want the local-data-ptr stuff

Let me know if you have success
Also, you may need to change this line:
module-config: "iterator"
to
module-config: "iterator validator"

Not sure if that will be strictly necessary for this case.
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Thanks! It's a little late now, but will have another play tomorrow...
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
No, it's got me a little stumped!

I haven't added much to your unbound.conf file, but I can't get the service to start and the error points to the first line I've added!!

Code:
## DrKK's Simple recursive caching DNS pool                                                                                        
##                                                                                                                                 
## Conservative system resource usage for ZFS/FreeNAS environment.                                                                 
## ***NOT*** appropriate for a heavily loaded environment!                                                                         
##                                                                                                                                 
## This uses settings that are pretty minimal---i.e., I expect                                                                     
## this keeps the memory footprint low, while generally offering                                                                   
## full performance for the typical home/small business user.  These                                                               
## settings would be ridiculous for a large enterprise.                                                                            
#                                                                                                                                  
## DrKK can be found on the #FreeNAS irc channel, or in the forums                                                                 
## at http://forums.freenas.org/                                                                                                   
#                                                                                                                                  
## The DNS forwarders listed below work well for me.  DO YOUR RESEARCH.                                                            
#                                                                                                                                  
server:                                                                                                                            
  interface: 0.0.0.0                                                                                                               
# The following line assumes your LAN is on the usual 192.168.x.x network.  Change                                                 
# this setting if necessary.                                                                                                       
  access-control: 192.168.0.0/16 allow                                                                                             
  verbosity: 1                                                                                                                     
  statistics-interval: 3600                                                                                                        
  statistics-cumulative: yes                                                                                                       
#  outgoing-range: 800                                                                                                             
  outgoing-range: 256                                                                                                              
  num-threads: 1                                                                                                                   
  msg-cache-size: 1m                                                                                                               
  msg-cache-slabs: 1                                                                                                               
  num-queries-per-thread: 128                                                                                                      
  rrset-cache-size: 2m                                                                                                             
  rrset-cache-slabs: 1                                                                                                             
  infra-cache-numhosts: 16                                                                                                         
  infra-cache-slabs: 1                                                                                                             
  do-ip4: yes                                                                                                                      
  do-ip6: no                                                                                                                       
  do-udp: yes                                                                                                                      
  do-tcp: no                                                                                                                       
  logfile: "unbound.log"                                                                                                           
  use-syslog: no                                                                                                                   
  log-time-ascii: yes                                                                                                              
  private-address: 10.0.0.0/8                                                                                                      
  private-address: 172.16.0.0/12                                                                                                   
  private-address: 192.168.0.0/16                                                                                                  
  private-address: 169.254.0.0/16   
do-not-query-localhost: yes                                                                                                      
  log-queries: no                                                                                                                  
  identity: "unbound DNS running on FreeNAS"                                                                                       
  target-fetch-policy: "0 0 0 0 0"                                                                                                 
  prefetch: yes                                                                                                                    
  cache-max-ttl: 604800                                                                                                            
  module-config: "iterator validator"                                                                                              
                                                                                                                                   
                                                                                                                                   
forward-zone:                                                                                                                      
## This is a good set of resolvers for the eastern US.  Recommend                                                                  
## that you investigate the best servers for your location.  I recommend                                                           
## Steve Gibson's DNSBench: https://www.grc.com/dns/benchmark.htm                                                                  
  name: "."                                                                                                                        
  forward-addr: 194.168.4.100                                                                                                      
  forward-addr: 194.168.8.100                                                                                                      
  forward-addr: 8.8.8.8                                                                                                            
                                                                                                                                   
                                                                                                                                  
# OPTIONAL REMOTE CONTROL SETTINGS (comment out if desired)                                                                        
# You must run unbound-control-setup before unbound-control can be used.                                                           
remote-control:                                                                                                                    
  control-enable: yes   

# locally served zones can be configured for the machines on the LAN.

     local-zone: "local." static                                                                                                       
                                                                                                                                   
local-data: "apeserver.local. IN A 192.168.168.50"                                                                                 
local-data: "freenas1.local.  IN A 192.168.168.65"                                                                                 
local-data: "freenas2.local.  IN A 192.168.168.165"                                                                                
local-data: "owncloud.local.  IN A 192.168.168.69"                                                                                  


Tried it with an without the change to the module-config setting but it doesn't like the first local-zone entry

This is my /etc/resolv.conf too, which I think is OK?

Code:
search local                                                                   
nameserver 192.168.168.68


Not much of a clue in the error message, other than the location:

Code:
root@unbound:/usr/local/etc/unbound # service unbound restart                                                                      
Stopping unbound.                                                                                                                  
Waiting for PIDS: 8000.                                                                                                            
/usr/local/etc/unbound/unbound.conf:90: error: syntax error                                                                        
read /usr/local/etc/unbound/unbound.conf failed: 1 errors in configuration file                                                    
Starting unbound.                                                                                                                  
/usr/local/etc/unbound/unbound.conf:90: error: syntax error                                                                        
read /usr/local/etc/unbound/unbound.conf failed: 1 errors in configuration file                                                     
 

adrianwi

Guru
Joined
Oct 15, 2013
Messages
1,231
Well, I've kind of got this working using a different unbound.conf file from the calomel.org linked above, although still can't really see why it wasn't working with the changes I'd made to yours!

Code:
## Authoritative, validating, recursive caching DNS
## unbound.conf -- https://calomel.org
#
server:
  # log verbosity
    verbosity: 1

  # specify the interfaces to answer queries from by ip-address.  The default
  # is to listen to localhost (127.0.0.1 and ::1).  specify 0.0.0.0 and ::0 to
  # bind to all available interfaces.  specify every interface[@port] on a new
  # 'interface:' labeled line.  The listen interfaces are not changed on
  # reload, only on restart.
    interface: 0.0.0.0

  # port to answer queries from
    port: 53

  # Enable IPv4, "yes" or "no".
    do-ip4: yes

  # Enable IPv6, "yes" or "no".
    do-ip6: no

  # Enable UDP, "yes" or "no".
    do-udp: yes

  # Enable TCP, "yes" or "no". If TCP is not needed, Unbound is actually
  # quicker to resolve as the functions related to TCP checks are not done.i
  # NOTE: you may need tcp enabled to get the DNSSEC results from *.edu domains
  # due to their size.
    do-tcp: yes

  # control which client ips are allowed to make (recursive) queries to this
  # server. Specify classless netblocks with /size and action.  By default
  # everything is refused, except for localhost.  Choose deny (drop message),
  # refuse (polite error reply), allow (recursive ok), allow_snoop (recursive
  # and nonrecursive ok)
    access-control: 127.0.0.0/8 allow
    access-control: 192.168.0.0/16 allow

  # Read  the  root  hints from this file. Default is nothing, using built in
  # hints for the IN class. The file has the format of  zone files,  with  root
  # nameserver  names  and  addresses  only. The default may become outdated,
  # when servers change,  therefore  it is good practice to use a root-hints
  # file.  get one from ftp://FTP.INTERNIC.NET/domain/named.cache
    root-hints: "/usr/local/etc/unbound/root.hints"

  # enable to not answer id.server and hostname.bind queries.
    hide-identity: yes

  # enable to not answer version.server and version.bind queries.
    hide-version: yes

  # Will trust glue only if it is within the servers authority.
  # Harden against out of zone rrsets, to avoid spoofing attempts.
  # Hardening queries multiple name servers for the same data to make
  # spoofing significantly harder and does not mandate dnssec.
    harden-glue: yes

  # Require DNSSEC data for trust-anchored zones, if such data is absent, the
  # zone becomes  bogus.  Harden against receiving dnssec-stripped data. If you
  # turn it off, failing to validate dnskey data for a trustanchor will trigger
  # insecure mode for that zone (like without a trustanchor).  Default on,
  # which insists on dnssec data for trust-anchored zones.
    harden-dnssec-stripped: yes

  # Use 0x20-encoded random bits in the query to foil spoof attempts.
  # http://tools.ietf.org/html/draft-vixie-dnsext-dns0x20-00
  # While upper and lower case letters are allowed in domain names, no significance
  # is attached to the case. That is, two names with the same spelling but
  # different case are to be treated as if identical. This means calomel.org is the
  # same as CaLoMeL.Org which is the same as CALOMEL.ORG.
    use-caps-for-id: yes

  # the time to live (TTL) value lower bound, in seconds. Default 0.
  # If more than an hour could easily give trouble due to stale data.
    cache-min-ttl: 3600

  # the time to live (TTL) value cap for RRsets and messages in the
  # cache. Items are not cached for longer. In seconds.
    cache-max-ttl: 604800

  # perform prefetching of close to expired message cache entries.  If a client
  # requests the dns lookup and the TTL of the cached hostname is going to
  # expire in less than 10% of its TTL, unbound will (1st) return the ip of the
  # host to the client and (2nd) pre-fetch the dns request from the remote dns
  # server. This method has been shown to increase the amount of cached hits by
  # local clients by 10% on average.
    prefetch: yes

  # number of threads to create. 1 disables threading. This should equal the number
  # of CPU cores in the machine. Our example machine has 4 CPU cores.
    num-threads: 1


  ## Unbound Optimization and Speed Tweaks ###

  # the number of slabs to use for cache and must be a power of 2 times the
  # number of num-threads set above. more slabs reduce lock contention, but
  # fragment memory usage.
    msg-cache-slabs: 2
    rrset-cache-slabs: 2
    infra-cache-slabs: 2
    key-cache-slabs: 2

  # Increase the memory size of the cache. Use roughly twice as much rrset cache
  # memory as you use msg cache memory. Due to malloc overhead, the total memory
  # usage is likely to rise to double (or 2.5x) the total cache memory. The test
  # box has 4gig of ram so 256meg for rrset allows a lot of room for cacheed objects.
    rrset-cache-size: 2m
    msg-cache-size: 1m

  # buffer size for UDP port 53 incoming (SO_RCVBUF socket option). This sets
  # the kernel buffer larger so that no messages are lost in spikes in the traffic.
    so-rcvbuf: 1m

  ## Unbound Optimization and Speed Tweaks ###


  # Enforce privacy of these addresses. Strips them away from answers.  It may
  # cause DNSSEC validation to additionally mark it as bogus.  Protects against
  # 'DNS Rebinding' (uses browser as network proxy).  Only 'private-domain' and
  # 'local-data' names are allowed to have these private addresses. No default.
    private-address: 10.0.0.0/8
    private-address: 172.16.0.0/12
    private-address: 10.0.0.0/16
    private-address: 192.168.0.0/16

  # Allow the domain (and its subdomains) to contain private addresses.
  # local-data statements are allowed to contain private addresses too.
    private-domain: "ape."

  # If nonzero, unwanted replies are not only reported in statistics, but also
  # a running total is kept per thread. If it reaches the threshold, a warning
  # is printed and a defensive action is taken, the cache is cleared to flush
  # potential poison out of it.  A suggested value is 10000000, the default is
  # 0 (turned off). We think 10K is a good value.
    unwanted-reply-threshold: 10000

  # IMPORTANT FOR TESTING: If you are testing and setup NSD or BIND  on
  # localhost you will want to allow the resolver to send queries to localhost.
  # Make sure to set do-not-query-localhost: yes . If yes, the above default
  # do-not-query-address entries are present.  if no, localhost can be queried
  # (for testing and debugging).
    do-not-query-localhost: yes

  # File with trusted keys, kept up to date using RFC5011 probes, initial file
  # like trust-anchor-file, then it stores metadata.  Use several entries, one
  # per domain name, to track multiple zones. If you use forward-zone below to
  # query the Google DNS servers you MUST comment out this option or all DNS
  # queries will fail.
  # auto-trust-anchor-file: "/usr/local/etc/unbound/root.key"

  # Should additional section of secure message also be kept clean of unsecure
  # data. Useful to shield the users of this validator from potential bogus
  # data in the additional section. All unsigned data in the additional section
  # is removed from secure messages.
    val-clean-additional: yes

  # Blocking Ad Server domains. Google's AdSense, DoubleClick and Yahoo
  # account for a 70 percent share of all advertising traffic. Block them.
  #  local-zone: "doubleclick.net" redirect
  #  local-data: "doubleclick.net A 127.0.0.1"
  #  local-zone: "googlesyndication.com" redirect
  #  local-data: "googlesyndication.com A 127.0.0.1"
  #  local-zone: "googleadservices.com" redirect
  #  local-data: "googleadservices.com A 127.0.0.1"
  #  local-zone: "google-analytics.com" redirect
  #  local-data: "google-analytics.com A 127.0.0.1"
  #  local-zone: "ads.youtube.com" redirect
  #  local-data: "ads.youtube.com A 127.0.0.1"
  #  local-zone: "adserver.yahoo.com" redirect
  #  local-data: "adserver.yahoo.com A 127.0.0.1"
  #  local-zone: "ask.com" redirect
  #  local-data: "ask.com A 127.0.0.1"


  # Unbound will not load if you specify the same local-zone and local-data
  # servers in the main configuration as well as in this "include:" file. We
  # suggest commenting out any of the local-zone and local-data lines above if
  # you suspect they could be included in the unbound_ad_servers servers file.
  #include: "/usr/local/etc/unbound/unbound_ad_servers"

  # locally served zones can be configured for the machines on the LAN.

    local-zone: "ape." static

    local-data: "freenas1.ape.  IN A 192.168.168.65"
    local-data: "freenas2.ape    IN A 192.168.168.165"
    local-data: "apeserver.ape.   IN A 192.168.168.50"
    local-data: "owncloud.ape.       IN A 192.168.168.69"
 

    local-data-ptr: "192.168.168.65  freenas1.ape"
    local-data-ptr: "192.168.168.165  freenas2.ape"
    local-data-ptr: "192.168.168.50  apeserver.ape"
    local-data-ptr: "192.168.168.69  owncloud.ape"

  # Unbound can query your NSD or BIND server for private domain queries too.
  # On our NSD page we have NSD configured to serve the private domain,
  # "home.lan". Here we can tell Unbound to connect to the NSD server when it
  # needs to resolve a *.home.lan hostname or IP.
  #
  # private-domain: "ape."
  # local-zone: "192.168.168.in-addr.arpa." nodefault
  # stub-zone:
  #      name: "ape."
  #      stub-addr: 192.168.168.68@53

  # If you have an internal or private DNS names the external DNS servers can
  # not resolve, then you can assign domain name strings to be redirected to a
  # seperate dns server. For example, our comapny has the domain
  # organization.com and the domain name internal.organization.com can not be
  # resolved by Google's public DNS, but can be resolved by our private DNS
  # server located at 1.1.1.1. The following tells Unbound that any
  # organization.com domain, i.e. *.organization.com be dns resolved by 1.1.1.1
  # instead of the public dns servers.
  #
  # forward-zone:
  #    name: "organization.com"
  #    forward-addr: 1.1.1.1        # Internal or private DNS

  # Use the following forward-zone to forward all queries to Google DNS,
  # OpenDNS.com or your local ISP's dns servers for example. To test resolution
  # speeds use "drill calomel.org @8.8.8.8" and look for the "Query time:" in
  # milliseconds.
  #
    forward-zone:
       name: "."
       forward-addr: 194.168.4.100  #Virgin Media ISP1
       forward-addr: 194.168.8.100  #Virgin Media ISP2
       forward-addr: 8.8.8.8        # Google Public DNS
      
#
## Authoritative, validating, recursive caching DNS
## unbound.conf -- https://calomel.org


Changed the local-zone to 'ape.' instead of 'local.' (and in resolv.conf) as I didn't know if my OS X server might not like that and it's less letters to type :D

Seems to work although not sure it's that much quicker than typing the IP addresses which I know pretty well anyway!

Stumbled across this though, which might be a useful tool for people to add into your jail - dnstop

Thanks again for a great guide. It really is a piece of cake setting up a DNS jail in FreeNAS, when you know how ;)
 

JJT211

Patron
Joined
Jul 4, 2014
Messages
323
Im having an issue with changing the ownership of the unbound.conf file using the chown command. It's kind of hard to see the command, but I believe I have the syntax correct from the video. Not sure if it makes a difference, but im using putty.



Code:
root@dns_server:/usr/local/etc/unbound # ll
total 25
-rw-r--r--  1 root  wheel    616 Mar 21 17:34 unbound.conf
-rw-r--r--  1 root  wheel  24756 Mar 21 17:00 unbound.conf.sample
root@dns_server:/usr/local/etc/unbound # ls -al
total 37
drwxr-xr-x   2 unbound  wheel      4 Mar 21 17:34 .
drwxr-xr-x  14 root     wheel     17 Mar 21 17:00 ..
-rw-r--r--   1 root     wheel    616 Mar 21 17:34 unbound.conf
-rw-r--r--   1 root     wheel  24756 Mar 21 17:00 unbound.conf.sample
root@dns_server:/usr/local/etc/unbound # chown unbound:unbound x
chown: x: No such file or directory
root@dns_server:/usr/local/etc/unbound #
 
Last edited:

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
Sir, I think the problem is you used the filename "x" in the first case, instead of the wildcard "*".

If you watch the video in 1080p, and fullscreen it, you'll see every command clearly.
 

JJT211

Patron
Joined
Jul 4, 2014
Messages
323
homer-simpson-doh-400x288.jpg
 

JJT211

Patron
Joined
Jul 4, 2014
Messages
323
OK thx for the help, got it all setup in FreeNAS and looking through the dump cache it appears its working.

I have a few questions about my LAN. I have the unbound DNS set in my router, which is running DD-WRT and I noticed right below where I input my DNS addresses, there's a check mark for DNSmasq for DNS (meaning it currently active). Should I leave that checked?

Im thinking that maybe I should as it would need that service for the backup DNS servers in the router config. But im wondering if that will conflict at all with my primary configuration (unbound).

Also, when I do a tracert in windows, nowhere do I see my unbound ip. Is that due to a) I just finished setting it up 20 mins ago or b) the router controls the DNS lookup as far as my laptop is concerned?

EDIT: The more I think of it, I should prob uncheck it, as if there's no settings in the router, then it just defaults to the local ISP's DNS correct? So more than likely, leaving that setting checked probably conflicts. Everything works fine with it unchecked anyways.

EDITv2: OK, dnsmasq for dns DEFINITELY conflicts. I ran DNS bench again and now my unbound jail is showing up! So anyone running DD-WRT/Tomato/ect, be sure to uncheck dnsmasq for dns
 
Last edited:

Atomic

Contributor
Joined
Oct 20, 2012
Messages
160
Hi,

I'd just set up the Unbound DNS server, following the youtube video. Everything worked fine until the point I tried to do the unbound-control dump_cache command. Just getting back error messages.

Code:
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound # unbound-control dump_cache
error: Error setting up SSL_CTX client key and cert
65891:error:02001002:system library:fopen:No such file or directory:/usr/src/secure/lib/libcrypto/../../../crypto/openssl/crypto/bio/bss_file.c:356:fopen('/usr/local/etc/unbound/unbound_control.pem','r')
65891:error:20074002:BIO routines:FILE_CTRL:system lib:/usr/src/secure/lib/libcrypto/../../../crypto/openssl/crypto/bio/bss_file.c:358:
65891:error:140DC002:SSL routines:SSL_CTX_use_certificate_chain_file:system lib:/usr/src/secure/lib/libssl/../../../crypto/openssl/ssl/ssl_rsa.c:722:
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound # service unbound stop
Cannot 'stop' unbound. Set unbound_enable to YES in /etc/rc.conf or use 'onestop' instead of 'stop'.
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound # sysrc unbound_enable=yes
unbound_enable:  -> yes
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound # service unbound stop
unbound not running? (check /usr/local/etc/unbound/unbound.pid).
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound # service unbound start
/usr/local/etc/unbound/unbound_server.key: No such file or directory
[1445712778] unbound-checkconf[65948:0] fatal error: server-key-file: "/usr/local/etc/unbound/unbound_server.key" does not exist
Starting unbound.
Oct 24 20:52:58 unbound[65949:0] error: Error for server-cert-file: /usr/local/etc/unbound/unbound_server.pem
Oct 24 20:52:58 unbound[65949:0] error: Error in SSL_CTX use_certificate_chain_file crypto error:02001002:system library:fopen:No such file or directory
Oct 24 20:52:58 unbound[65949:0] error: and additionally crypto error:20074002:BIO routines:FILE_CTRL:system lib
Oct 24 20:52:58 unbound[65949:0] error: and additionally crypto error:140DC002:SSL routines:SSL_CTX_use_certificate_chain_file:system lib
Oct 24 20:52:58 unbound[65949:0] fatal error: could not set up remote-control
/usr/local/etc/rc.d/unbound: WARNING: failed to start unbound
root@Unbound_DNS:/usr/local/etc/unbound #
root@Unbound_DNS:/usr/local/etc/unbound # 


What happened?
 

DrKK

FreeNAS Generalissimo
Joined
Oct 15, 2013
Messages
3,630
You probably didn't set up unbound-control correctly. From the man page:
Code:

SET UP
  The setup requires a self-signed certificate and private keys for  both
  the  server  and  client.  The  script unbound-control-setup generates
  these in the default run directory, or with -d  in  another  directory.
  If  you  change the access control permissions on the key files you can
  decide who can use unbound-control, by default owner and group but  not
  all  users.  Run the script under the same username as you have config-
  ured in unbound.conf or as root, so that the  daemon  is  permitted  to
  read the files, for example with:
  sudo -u unbound unbound-control-setup
  If  you  have  not configured a username in unbound.conf, the keys need
  read permission for the user credentials  under  which  the  daemon  is
  started.  The  script preserves private keys present in the directory.
  After  running  the  script  as  root,  turn  on  control-enable  in
  unbound.conf.
 
Status
Not open for further replies.
Top