Primary server forward zone definition
Forward lookup zone for example.com
zone "example.com" IN {
type master;
file "example.com";
notify yes;
allow-update { none; };
};
Enterprise Linux
HOGENT applied computer science
Set up the test environment
$ cd elnx-syllabus/demo
$ vagrant up ns1 ns2
[...]
Hosts file: /etc/hosts
# IP-address hostname aliases
127.0.0.1 localhost localhost.localdomain
::1 localhost6 localhost6.localdomain6
172.22.255.254 router4038 gw gw.netlab.hogent.be
172.22.0.2 server4038 server4038.netlab.hogent.be
172.22.0.3 printer4038 printer4038.netlab.hogent.be
c:\Windows\System32\Drivers\etc\hosts
Typical Active Directory Domain Controller violates both!
query the DNS server in /etc/resolv.conf
nslookup www.hogent.be
query the specified DNS server
nslookup www.hogent.be 193.190.172.1
$ dig www.hogent.be
[...]
$ dig www.hogent.be @ens1.hogent.be +short
hogent.be.
193.190.173.132
$ dig -x 193.190.173.132 @ens1.hogent.be +short
net-173-node-133.hogent.be.
$ dig AAAA www.google.com +short
2a00:1450:400e:806::2004
$ dig NS hogent.be
$ dig MX hogent.be
$ dig SOA hogent.be
$ dig ANY hogent.be @ens1.hogent.be
$ dig AXFR zonetransfer.me @nsztm1.digi.ninja
Read DNS for rocket scientists: http://www.zytrax.com/books/dns/
named
/etc/named*
/var/named/
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { any; };
directory "/var/named";
// ...
allow-query { any; };
allow-transfer { any; };
recursion no;
rrset-order { order random; };
// ...
};
listen-on
: port number + network interfaces
any;
127.0.0.0/8; 192.168.56.0/24
allow-query
: which hosts may send queries?allow-transfer
: which secondary name servers may receive zone transfers?recursion
: allow recursive queries
no
on authoritative name serverForward lookup zone for example.com
zone "example.com" IN {
type master;
file "example.com";
notify yes;
allow-update { none; };
};
On a secondary name server:
zone "example.com" IN {
type slave;
masters { 192.168.56.10; };
file "slaves/example.com";
};
zone "56.168.192.in-addr.arpa" IN {
type master;
file "56.168.192.in-addr.arpa";
notify yes;
allow-update { none; };
};
192.168.56.0/24
192.168.56
56.168.192
in-addr.arpa.
:
56.168.192.in-addr.arpa.
$ORIGIN example.com.
$TTL 1W
@ IN SOA ns1.example.com. hostmaster.example.com. (
18042020 1D 1H 1W 1D )
IN NS ns1
IN NS ns2
ns1 IN A 192.168.56.10
ns2 IN A 192.168.56.11
dc IN A 192.168.56.40
web IN A 192.168.56.172
www IN CNAME web
db IN A 192.168.56.173
priv0001 IN A 172.16.0.10
priv0002 IN A 172.16.0.11
web IN A 192.168.56.172
www IN CNAME web
A
: name → IPAAAA
: name → IPv6PTR
: IP → nameCNAME
: aliasSOA
: start of authority, info about the domainNS
: authoritative name server(s)MX
: mail serverSRV
: serviceTXT
: text record@ IN SOA ns1.example.com. hostmaster.example.com. (
18042020 1D 1H 1W 1D )
ns1.example.com.
: primary name serverhostmaster.example.com.
: email address of sysadmin
hostmaster@example.com
18042020
: serial
@ IN SOA ns1.example.com hostmaster.example.com (
18042020 1D 1H 1W 1D )
1D
: when will secondary ns try to refresh the zone1H
: time between update retries1W
: when is zone data no longer authoritative (only secondary)1D
: how long can NAME ERROR result be cached$ORIGIN
: domain name
.
@
: replaced with value of $ORIGIN
$TTL
: time to live (in seconds)
$ORIGIN
added to the endCombinations are allowed, e.g. 2H30M
$TTL 1W
$ORIGIN 16.172.in-addr.arpa.
@ IN SOA ns1.example.com. hostmaster.example.com. (
18042020
1D 1H 1W 1D )
IN NS ns1.example.com.
IN NS ns2.example.com.
10.0 IN PTR priv0001.example.com.
11.0 IN PTR priv0002.example.com.
Every (forwarding) name server should have list of root name servers
dig @a.root-servers.net
. 518400 IN NS a.root-servers.net.
. 518400 IN NS b.root-servers.net.
[...]
a.root-servers.net. 518400 IN A 198.41.0.4
b.root-servers.net. 518400 IN A 199.9.14.201
[...]
a.root-servers.net. 518400 IN AAAA 2001:503:ba3e::2:30
b.root-servers.net. 518400 IN AAAA 2001:500:200::b
[...]
Authoritative name server for domain example.com
Host | IP |
---|---|
ns1 | 192.168.56.10 |
ns2 | 192.168.56.11 |
dc | 192.168.56.40 |
web | 192.168.56.72 |
db | 192.168.56.73 |
priv0001 | 172.16.0.10 |
priv0002 | 172.16.0.11 |
The host web
has an alias, www
.
[vagrant@ns1]$ /vagrant/tests/runtests.sh
Testing 192.168.56.10
✓ The dig command should be installed
✓ It should return the NS record(s)
✓ It should be able to resolve host names
✓ It should be able to do reverse lookups
✓ It should be able to resolve aliases
✓ It should return the SRV record(s)
6 tests, 0 failures
Testing 192.168.56.11
✓ The dig command should be installed
✓ It should return the NS record(s)
✓ It should be able to resolve host names
✓ It should be able to do reverse lookups
✓ It should be able to resolve aliases
✓ It should return the SRV record(s)
6 tests, 0 failures
journalctl -f -l -u named
named-checkconf /etc/named.conf
named-checkzone ZONE FILE
$ named-checkconf
$ named-checkzone example.com /var/named/example.com
$ named-checkzone 16.172.in-addr.arpa /var/named/16.172.in-addr.arpa
Enable Query log:
[root@ns1 ~]# rndc querylog
Force zone update:
[root@ns2 ~]# rndc refresh example.com
Follow BIND logs:
[root@ns1 ~]# journalctl -f -u named.service
Capture network traffic:
[root@ns2 ~]# tcpdump -i eth1 -vvnnttt
[root@ns2 ~]# tcpdump -i eth1 -U -w - | tee dns.pcap | tcpdump -vv -nn -ttttt -r -