apt-get install bind9 bind9utils bind9-doc
Before continuing, let’s set BIND to IPv4 mode. On both servers, edit the bind9 service parameters file:
sudo vi /etc/default/bind9
Add “-4” to the OPTIONS variable. It should look like the following:
OPTIONS="-4 -u bind"
Save and exit.
Add the new section to /etc/bind/named.conf.options:
acl “trusted” {
192.168.246.130; # myself – can be set to localhost
192.168.246.132; # host2
};
Now that we have our list of trusted DNS clients, we will want to edit the options block. Currently, the start of the block looks like the following:
options {
directory "/var/cache/bind";
...
}
Below the directory directive, add the highlighted configuration lines (and substitute in the proper ns1IP address) so it looks something like this:
options {
directory "/var/cache/bind";
recursion yes; # enables resursive queries
allow-recursion { trusted; }; # allows recursive queries from "trusted" clients
listen-on { 192.168.246.130; }; # ns1 private IP address - listen on private network only
allow-transfer { none; }; # disable zone transfers by default
forwarders {
8.8.8.8;
8.8.4.4;
};
...
};
Now save and exit named.conf.options. The above configuration specifies that only your own servers (the “trusted” ones) will be able to query your DNS server.
root@ubuntu:/etc/bind# more named.conf.local
zone “robert321.com” {
type master;
file “/etc/bind/zones/robert.com.db”;
};
zone “246.168.192.in-addr.arpa”{
type master;
file “/etc/bind/zones/rev.246.168.192.in-addr.arpa”;
};
root@ubuntu:/etc/bind/zones# more robert.com.db
robert321.com. IN SOA ubuntu.robert321.com. admin.robert321.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
robert321.com. IN NS ubuntu.robert321.com.
ubuntu IN A 192.168.246.130
ubuntu2 IN A 192.168.246.132
root@ubuntu:/etc/bind/zones# more rev.246.168.192.in-addr.arpa
@ IN SOA ubuntu.robert321.com. admin.robert321.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ubuntu.robert321.com.
130 IN PTR ubuntu.robert321.com.
132 IN PTR ubuntu2.robert321.com.
root@ubuntu:/etc/resolvconf/resolv.conf.d# resolvconf -u
root@ubuntu:/etc/resolvconf/resolv.conf.d#
root@ubuntu:/etc/resolvconf/resolv.conf.d#
root@ubuntu:/etc/resolvconf/resolv.conf.d# ls
base head
root@ubuntu:/etc/resolvconf/resolv.conf.d# more head
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN
search robert321.com
nameserver 192.168.246.130
The post Configure a DNS server on ubuntu appeared first on Robert Chen.