2

I have a network, with no internet connection, with a few computers and a raspberry pi on it. I want to setup a DNS server on the raspberry pi so that the computers on the network may use it.

For example, they could go to example.com and it would go through to the server (which is on a static IP address). Other websites, like google.com, would not work because of the lack of internet connection on the network.

I would prefer to use BIND9, but any other dns server software would work.

Questions

  • Is there a tutorial for this?
  • How would I direct the traffic to the DNS server in the router settings?
2

In order to set up routes, you'll need to set up dhcpd, which will assign local IP addresses, as well as push routes.

In order to resolve hostnames, you need a DNS server, which BIND9 does a great job handling.

The following uses domain.tld as the domain being used, and 10.1.0.1 as the GATEWAY/ROUTER's IP. Also, somename is used to represent a client to your network.

/etc/dhcp/dhcpd.conf

# Zone Set Up
zone domain.tld {
       primary 10.1.0.1;
}


# Additional Information
ddns-domainname "domain.tld";
ddns-rev-domainname "in-addr.arpa.";
option domain-name "domain.tld";
option domain-name-servers 10.1.0.1;
option broadcast-address 10.1.0.255;

# Routes
option classless-static-routes
                            0,      0,0,0,0,
                            0,      10,1,0,1,
                            24,     10,1,0,         10,1,0,1;

# Push Routes to Clients
subnet 10.1.0.0 netmask 255.255.255.0 {
        range 10.1.0.100 10.1.0.254;
        option routers 10.1.0.1;
        zone 0.1.10.in-addr.arpa. {
                primary 10.1.0.1;
        }
        zone domain.tld. {
                primary 10.1.0.1;
        }
}

The above assumes that your GATEWAY/ROUTER will be 10.1.0.1. You will need to select which 'domain.tld' you'd like to use. This will cause all routes to go to the gateway, 10.1.0.1.

This is also where you could specify IP addresses using the client's MAC address. This gives you DHCP, with psuedo-static IPs.

host somename {
        hardware ethernet 60:XX:4c:XX:8a:XX;
        fixed-address 10.1.0.100;
}

/var/lib/bind/db.0.1.10

$TTL    86400 ; 24 hours could have been written as 24h or 1d
;$ORIGIN 0.1.10.in-addr.arpa.
@  1D  IN    SOA domain.tld.   admin.domain.tld. (
                  2002022401 ; serial
                  3H ; refresh
                  15 ; retry
                  1w ; expire
                  3h ; minimum
                 )
; server host definitions
@      IN  NS     domain.tld.
1      IN  PTR    domain.tld.
100    IN  PTR    somename.domain.tld

This says "admin@domain.tld is the contact for these IPs and 10.1.0.1 is 'domain.tld'". You could add other IPs pointing to other subdomains.

125   IN   PTR   sub.domain.tld.

Adding this would tell reverse lookups that 10.1.0.125 is sub.domain.tld.

/var/lib/bind/db.domain.tld

$ORIGIN .
$TTL 604800 ; 1 week
domain.tld    IN SOA  domain.tld. admin.domain.tld. (
        205        ; serial
        604800     ; refresh (1 week)
        86400      ; retry (1 day)
        2419200    ; expire (4 weeks)
        604800     ; minimum (1 week)
        )
      NS  10.1.0.1.
      A 10.1.0.1
router         A 10.1.0.1
somename       A 10.1.0.100
*           CNAME domain.tld.

This says "admin@domain.tld is the contact for these domains and 'domain.tld' is 10.1.0.1". You could add other domains, and even subdomains, pointing to other devices/ips.

router.domain.tld will resolve to 10.1.0.1. This also redirects (CNAMES) any not-mentioned subdomain (whatever.domain.tld) to domain.tld.

/etc/bind/named.conf.local

This file will tell bind to load the previous db files we've created.

zone "domain.tld" {
        type master;
        file "/var/lib/bind/db.domain.tld";
};

zone "0.1.10.in-addr.arpa" {
        type master;
        file "/var/lib/bind/db.0.1.10";
};

Notes

There are plenty of tutorials on how to 'set up a gateway on Debian'.

| improve this answer | |
  • So would I need to set the server as "default gateway" in the router settings? Also would I need to disable the dchp server built into the router? @earthmeLon – harry_p_6 Nov 5 '14 at 17:12
  • If your setup is Client -> Router -> Gateway, you will want to set up DHCP Forwarding on the Router (DD-WRT) or have the Router on a different subnet and hand out IPs for that subnet. – earthmeLon Nov 11 '14 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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