Linux LAN domain – BIND9 and Debian

Disclaimer :: the information in this post was altered in order to avoid disclosing the real details of our internal network.

I wanted to change my LAN domain to srv.dth. All devices connected to my network must resolve this domain automatically and certain devices will have their own FQDN, like: printer.srv.dth.


domain:  srv.dth
network: 10.0.0.0
host:    hs.srv.dth       // "home server", machine where the DNS server will run
host IP: 10.0.0.10

devices:
router.srv.dth            // ISP router
router1.srv.dth           // Home network
router2.srv.dth           // Lab 
hs.srv.dth                // DNS server
printer.srv.dth           // Printer
cam0.srv.dth              // Security cameras
cam1.srv.dth
cam2.srv.dth

vim /etc/hosts

127.0.0.1       localhost.localdomain   localhost
10.0.0.10	hs.srv.dth	     	hs

vim /etc/hostname

hs

install bind

apt-get update && apt-get install bind9 bind9utils

Now reboot

reboot

Type hostname and hostname -f

# hostname
hs
# hostname -f
hs.srv.dth

Add to named.conf.local:

zone "srv.dth" IN {
  // this is the authoritative server for srv.dth
  type master;
  file "/etc/bind/zones/srv.dth";
  allow-query { any; };
};

zone "0.0.10.in-addr.arpa" {
  // this is the authoritative server for
  // the 10.0.0.0 network
  type master;
  file "/etc/bind/zones/rev.10.0.0";
};

After mkdir /etc/bind/zones, create the DNS zone file with vim /etc/bind/zones/srv.dth

;
; DNS zone for srv.dth
;
$ORIGIN srv.dth.    ; designates the start of this zone file in the namespace
$TTL 1h            ; default expiration time of all resource records without their own TTL value
@        IN  SOA   ns.srv.dth. admin.srv.dth. (
                        2017050101   ; serial
                        8H           ; refresh
                        4H           ; retry
                        4W           ; expire
                        1D )         ; minimum
;
; Name Server and Mail eXchange
;
srv.dth.  IN  NS    ns.srv.dth.        ; ns.srv.dth is a nameserver for srv.dth
@         IN  NS    ns2.srv.dth.       ; ns.somewhere.example is a backup nameserver for srv.dth
@         IN  MX    10 mail.srv.dth.   ; mail.srv.dth is the mailserver for srv.dth
;
; Hosts
;
srv.dth.  IN  A     10.0.0.10
ns        IN  A     10.0.0.10
mail      IN  A     10.0.0.10
www       IN  CNAME srv.dth.
cloud     IN  CNAME srv.dth.
router0   IN  A     192.168.1.1
router1   IN  A     10.0.0.1
router2   IN  A     10.0.0.2
printer   IN  A     10.0.0.15
cam0      IN  A     10.0.0.20
cam1      IN  A     10.0.0.21
cam2      IN  A     10.0.0.22

Then create the reverse zone with vim /etc/bind/zones/rev.10.0.0

;
; reverse pointers for 10.0.0.0 subnet
;
$ORIGIN 0.0.10.in-addr.arpa.
$TTL 1D
@        IN  SOA   ns.srv.dth. admin.srv.dth. (
                       2017050101     ; serial
                       8H             ; refresh
                       4H             ; retry
                       4W             ; expire
                       1D )           ; minimum
;
; Define the authoritative name server
;
              NS      ns.srv.dth.
;
; Hosts
;
10            PTR     hs.srv.dth.     ; 1 for the last digit of 10.0.0.10
10            PTR     ns.srv.dth.
10            PTR     www.srv.dth.
10            PTR     cloud.srv.dth.
10            PTR     mail.srv.dth.
10            PTR     cloud.srv.dth.
1             PTR     router1.srv.dth.
2             PTR     router2.srv.dth.
15            PTR     printer.srv.dth. ; 15 for the last digit of 10.0.0.15
20            PTR     cam0.srv.dth.
21            PTR     cam1.srv.dth.
22            PTR     cam2.srv.dth.

Now make sure hs.srv.dth has a static IP and that both hs.srv.dth and its router will have only 10.0.0.10 (hs’s ip) as DNS. Also if using network-manager, make sure to disable dnsmasq with vim /etc/NetworkManager/NetworkManager.conf

#dns=dnsmasq

I always like to reboot both hs.srv.dth and the router. After that, I reconnect to the network from my laptop and can check if it works by typing printer.srv.dth on my browser.

And from a console

[dth@slayer ~]$ host srv.dth
srv.dth has address 10.0.0.10
srv.dth mail is handled by 10 mail.srv.dth.
[dth@slayer ~]$ host 10.0.0.10
10.0.0.10.in-addr.arpa domain name pointer mail.srv.dth.
10.0.0.10.in-addr.arpa domain name pointer www.srv.dth.
10.0.0.10.in-addr.arpa domain name pointer ns.srv.dth.
10.0.0.10.in-addr.arpa domain name pointer hs.srv.dth.
10.0.0.10.in-addr.arpa domain name pointer cloud.srv.dth.
[dth@slayer ~]$ host 10.0.0.15
15.0.0.10.in-addr.arpa domain name pointer printer.srv.dth.
[dth@slayer ~]$ host 10.0.0.20
20.0.0.10.in-addr.arpa domain name pointer cam0.srv.dth.

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading Facebook Comments ...
Loading Disqus Comments ...