1

I have configured my own DNS server and want to make it possible for everyone on the subnet to lookup each other.

How do I do that?

0

1 Answer 1

0

First, you need a DNS server. BIND Install BIND is example of widely used and standard server.

Below is an example for:

  • network named local.example.com
  • with IP addresses 192.168.0.0
  • and netmask 255.255.255.0 (24 bits)

For server:

  • named ns1
  • with IP number 192.168.0.1

And for 2 external DNS servers of:

  • 1.2.3.4
  • 1.2.3.5

Change those values accordingly to fit your network structure.

1. Install BIND

sudo apt-get install bind9

2. Add your local domain

In BINDs configuration file of /etc/named.conf.local add config for name queries (name to IP number):

zone "local.example.com" {
    type master;
    file "/etc/bind/db.local.example.com";
    allow-query { 192.168.0.0.0/24; 127.0.0.1; };
};

And for reverse queries (IP numbers to names):

zone "0.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192.168.0";
    allow-query { 192.168.0.0/24; 127.0.0.1; };
};

Create two configuration files for your network. In /etc/bind/db.local.example.com, put:

$TTL    604800
@       IN      SOA     local.example.com. hostmaster.example.com. (
                        1503281         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.local.example.com.
ns1     IN      A       192.168.0.1
;
; Local computers
comp1   IN      A       192.168.0.101
comp2   IN      A       192.168.0.102
comp3   IN      A       192.168.0.103

In /etc/bind/db.192.168.0 put:

$TTL    604800
@       IN      SOA     v1.local.example.com. hostmaster.example.com. (
                        1503281         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns1.
1       IN      PTR     ns1.local.example.com.
; Local computers
101      IN      PTR     comp1.local.example.com.
102      IN      PTR     comp2.local.example.com.
103      IN      PTR     comp3.local.example.com.

Note the Serial parameter: It may contain any number, and it should be changed every time you make changes to your config file. In this example it is constructed from date and unique number (YYMMDDN).

3. External resolutions

Your server needs to resolve other queries, configure external DNS servers in /etc/bind/named.conf.options as "forwarders":

 options {
    forwarders {
        1.2.3.4;
        1.2.3.5;
    };
    [...]
}

4. Load configuration

You can reload configuration by:

sudo service bind9 reload

Check /var/log/syslog if there is no errors loading your new configs.

5. Usage

You should now be able to query your DNS server from localhost and from clients of 192.168.0.0/24 network. They need to be configured to use this server (192.168.0.1) and this domainname (local.example.com) - eg. with DHCP configuration or statically in /etc/network/interfaces, like this:

auto eth0
iface eth0 inet static
        address 192.168.0.101
        netmask 255.255.255.0
        gateway 192.168.0.1
        dns-nameservers 192.168.0.1
        dns-search local.example.com

To test your DNS on client machine (before switching permanently) you can try:

host comp1 192.168.0.1
3
  • hello. thanks for this. just one question. if I want 250+ computer on my subnet to connect to my DNS, do I have to write all of them (comp1 to comp250+) or is there another way to do this faster?
    – salim
    Mar 29, 2015 at 12:31
  • can I ask you why you have 127.0.0.1 in allow-query? isnt subnet enough
    – salim
    Mar 29, 2015 at 13:19
  • As far as I know localhost is needed if you want to use server by its own, you need this for at least testing purposes. If you have all computers named with one pattern you could use DDNS with DHCP, try to search web and questions related to it and/or create new question if you need.
    – madneon
    Mar 29, 2015 at 16:06

Not the answer you're looking for? Browse other questions tagged .