Setting up home DNS with Ubuntu Server

Posted by Zeophlite on Server Fault See other posts from Server Fault or by Zeophlite
Published on 2013-10-24T07:36:50Z Indexed on 2013/10/24 15:57 UTC
Read the original article Hit count: 228

Filed under:
|

I have a webserver (with static IP 192.168.1.5), and I want to have my machines on my local network to be able to access it without modifying /etc/hosts (or equivalent for Windows/OSX). My router has

Primary DNS server 192.168.1.5
Secondary DNS server 8.8.8.8 (Google's public DNS).

Nginx is set up to server websites externally as

*.example.com

Internally, I want

*.example.local

to point to the server.

My webserver has BIND9 installed, but I'm unsure of the settings. I've been through various contradicting tutorials, and so most of my settings have been clobbered. I've stripped out the lines which I'm confused about.

The tutorials I looked at are http://tech.surveypoint.com/blog/installing-a-local-dns-server-behind-a-hardware-router/ and http://ubuntuforums.org/showthread.php?t=236093 . They mostly differ on what should be put in /etc/bind/zones/db.example.local and /etc/bind/zones/db.192, so I've left the conflicting lines out below. Can someone suggest what the correct lines are to give my above behaviour (namely *.example.local pointing to 192.168.1.5)?

/etc/network/interfaces

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    address 192.168.1.5
    netmask 255.255.255.0
    broadcast 192.168.1.255
    gateway 192.168.1.254

/etc/hostname

avalon

/etc/resolv.conf

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN

/etc/bind/named.conf.options

options {
    directory "/var/cache/bind";

    forwarders {
        8.8.8.8;
        8.8.4.4;
    };

    dnssec-validation auto;

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
};

/etc/bind/named.conf.local

zone "example.local" {
    type master;
    file "/etc/bind/zones/db.example.local";
};

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/db.192";
};

/etc/bind/zones/db.example.local

$TTL    604800
@   IN  SOA avalon.example.local.   webadmin.example.local. (
                  5     ; Serial, increment each edit
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL

/etc/bind/zones/db.192

$TTL    604800
@   IN  SOA avalon.example.local.   webadmin.example.local. (
                  4     ; Serial, increment each edit
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;

What do I need to add to the above files so that on a laptop on the internal network, I can type in webapp.example.local, and be served by my webserver?

EDIT

I made several changes to the above files on the webserver.

/etc/network/interfaces (end of file)

    dns-nameservers 127.0.0.1
    dns-search example.local

/etc/bind/zones/db.example.local (end of file)

@   IN  NS  avalon.example.local.
@   IN  A   192.168.1.5
avalon  IN  A   192.168.1.5
webapp  IN  A   192.168.1.5
www IN  CNAME   192.168.1.5

/etc/bind/zones/db.192 (end of file)

    IN  NS  avalon.example.local.
73  IN  PTR avalon.example.local.

As a side note, my spare Win7 machine was able to connect directly to webapp.example.local, but for a Ubuntu 13.10 machine, I had to make the following changes as well (not on the webserver, but on a separate machine):

/etc/nsswitch.conf

before

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

after

hosts:          files dns

/etc/NetworkManager/NetworkManager.conf

before

dns=dnsmasq

after

#dns=dnsmasq

The issue remains that its not wildcard DNS, and so I have to add entries to /etc/bind/zones/db.example.local for webapp1, webapp2, ...

© Server Fault or respective owner

Related posts about ubuntu

Related posts about bind