How to create a IPv4 DNS server (master) on Debian

Old No Comments on How to create a IPv4 DNS server (master) on Debian 9

Chose a physical or, better, virtual machine and set its IP address to 192.168.0.40 (we’re using 192.168.0/24 in this example) and its hostname to ns.example.com where example.com is your chosen domain.

————————————————–

# apt-get purge isc-dhcp-client isc-dhcp-common dhcp3-client

————————————————–

# apt-get install bind9 dnsutils

————————————————–

# vi /etc/hosts

127.0.0.1 localhost.localdomain localhost

192.168.0.40 ns.example.com ns

::1 ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts

————————————————–

# vi /etc/resolv.conf

search example.com

nameserver 127.0.0.1

nameserver 8.8.4.4

————————————————–

# vi /etc/bind/named.conf.local

include “/etc/bind/zones.rfc1918”;

zone “example.com” {

type master;

file “db.example.com”;

};

zone “0.168.192.in-addr.arpa” {

type master;

file “db.192.168.0”;

};

————————————————–

# vi /var/cache/bind/db.example.com

$TTL 1d

@ IN SOA ns.example.com. hostmaster.example.com. (

1 ;serial

12h ;refresh

1h ;retry

24h ;expire

2h ;negative cache TTL

)

@ NS ns.example.com

ns IN A 192.168.0.40

router IN A 192.168.0.1

fisso IN A 192.168.0.200

————————————————–

# vi /var/cache/bind/db.192.168.0

$TTL 1d

@ IN SOA ns.example.com. hostmaster.example.com. (

1 ;serial

12h ;refresh

1h ;retry

24h ;expire

2h ;negative cache TTL

)

@ IN NS ns.example.com.

@ IN A 192.168.0.40

400.168.192.in-addr.arpa IN A ns.example.com.

10.168.192.in-addr.arpa IN A router.example.com.

200.0.168.192.in-addr.arpa IN A fisso.example.com.

————————————————–

# vi /etc/bind/named.conf.options

forwarders {

8.8.8.8;

};

————————————————–

For every GNU/Linux box

# vi /etc/resolv.conf

search example.com

nameserver 192.168.0.40

and, in a shell, use

# echo “kernel.domainname = example.com” >> /etc/sysctl.conf # sysctl -p

——-

For every Windows box use 10.0.0.40 as the primary DNS and add example.com as prefix.

Don’t use the host registration or you’ll get a lot of failed update in the bind9 logs related to the windows hosts.

Author

Luca Francesca

I’m a Junior Unix/Linux System Administrator who deals with networking (DNS), infrastructure (LDAP) and services (nginx,apache).

Related Articles

Leave a comment

Back to Top