0

I've been working on setting up a bind9 server on my home server running Ubuntu Server 16.04 to allow me to access my services by name rather than an IP address.

The bind server itself is (mostly) set up and working perfectly. I can resolve hostnames from ip addresses and ip addresses from hostnames from my network devices, but the server itself can't resolve anything from its own bind9 records and it's leaving me a little bit stumped.

The only nameservers in /etc/resolv.conf are my router 192.168.1.1 and 8.8.8.8.

These are setup in my /etc/network/interfaces. I'm assuming my problem is that 127.0.0.1 isn't in there, so the server itself is immediately looking to my router to resolve addresses and then to 8.8.8.8 but when I add 127.0.0.1 to /etc/network/interfaces then nothing else gets added to /etc/resolv.conf so I'm left with a single name server of 127.0.0.1

I do have forwarders set up in /etc/bind/named.conf.local, and they do work in that I can still access the internet, but from every guide I've read, bind9 should be adding 127.0.0.1 to /etc/resolv.conf itself meaning it's still also populated by the servers in my /etc/network/interfaces file so that my server is still "online" even if the bind server fails for some reason.

I've checked /etc/default/bind9 and RESOLVCONF=yes is there

# run resolvconf?
RESOLVCONF=yes

# startup options for the server
OPTIONS="-u bind"

Here's my /etc/network/interfaces in case something is wrong there

/etc/network/interfaces                                                                      

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo wlan0
iface lo inet loopback

# The primary network interface

#auto eth0
#       iface eth0 inet static

iface wlan0 inet static
        address 192.168.1.62
        netmask 255.255.255.0
        broadcast 192.168.1.255
        network 192.168.1.0
        wpa-ssid #############
        wpa-psk ****************
        dns-nameservers 192.168.1.1 8.8.8.8
        gateway 192.168.1.1
#       mtu 1500

Here's my /etc/bind/named.conf

acl mynetwork {
        192.168.1.0/24;
        };
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
key rndc-key {
        algorithm hmac-md5;
        secret "*****************";
        };
controls {
        inet 127.0.0.1 port 953 allow { 127.0.0.1; } keys { rndc-key; };
        };

And my /etc/bind/named.conf.options

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

        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders.
        // Uncomment the following block, and insert the addresses replacing
        // the all-0's placeholder.

        forwarders {
                192.168.1.1;
                208.67.222.222;
                208.67.220.220;
                8.8.8.8;
                8.8.4.4;
                };

        //========================================================================
        // If BIND logs error messages about the root key being expired,
        // you will need to update your keys.  See https://www.isc.org/bind-keys
        //========================================================================
        dnssec-validation auto;

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

If you need to see any of the zone files please ask, but I don't think they're the problem since name resolution works fine from other devices, just not from the server itself; unless I change my /etc/network/interfaces file and have 127.0.0.1 as my only dns server in /etc/resolv.conf so I guess this was a long winded way of me asking How do I add 127.0.0.1 to my list of dns in /etc/resolv.conf instead of having it as the only entry

0

I've found a solution (of sorts) to this myself.

I edited my /etc/resolvconf/head file and added the line nameserver 127.0.0.1 and put my /etc/network/interfaces nameserver section back to normal. I now have 127.0.0.1 as the first entry in my /etc/resolv.conf followed by the nameservers listed in my /etc/network/interfaces

I still don't know why bind wasn't adding the entry itself, but at least everything is now working.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.