Setting up home DNS with Ubuntu Server

2

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, ...

Zeophlite

Posted 2013-10-24T07:36:50.050

Reputation: 191

1

Zeophlite, please don't take thie the wrong way, but you've been a member for a while. Have you, all that time, managed to miss the line in bold in http://serverfault.com/help/on-topic that says that *SF is not for "Anything in a home or development environment"*?

– MadHatter – 2013-10-24T07:49:23.983

To be honest, I've never looked there, thank you for pointing it out. My previous questions have all been for professional work. Is there a StackExchange site that is more suitable for this question? If so, I'll move it there. – Zeophlite – 2013-10-24T07:53:40.870

@Zeophlite you could ask on SuperUser. However, if you edit out the referenced to "home networks" it's a well written, formatted question it might be OK and can stay here. – tombull89 – 2013-10-24T07:55:15.397

I'll leave it here for now then – Zeophlite – 2013-10-24T07:58:06.667

Fair enough - I do agree with tombull89 about it being a well-written question. Have you tried putting the single line IN A webapp 192.168.1.5 (with a leading TAB) in /etc/bind/zones/db.example.local? I understand you want wildcard DNS, reverse-resolution, and so on, but try getting a single forward host to work first, to simplify the problem. – MadHatter – 2013-10-24T08:05:23.223

@MadHatter, I've gotten the single forward to work, thanks to your help. I've updated the question to show the changes made. – Zeophlite – 2013-10-24T15:08:31.673

OK, have you now tried adding a wildcard record * IN A 192.168.1.5 (my sincere apologies for getting the fields in the wrong order above)? – MadHatter – 2013-10-24T15:50:13.177

Don't do this. Just use your example.com domain internally. It's much simpler, and it won't break your web apps, many of which do not support being accessed via multiple different domain names. – Michael Hampton – 2013-10-24T16:47:48.453

@MadHatter, In /etc/bind/zones/db.example.local changing webapp to * does not seem to work - I can't access webapp.example.local like I did beforehand – Zeophlite – 2013-10-25T00:23:53.673

No answers