Instalando o bind
root@ns1:~# aptitude install bind9 bind9utils
Arquivo de zonas
root@ns1:~# cat /etc/bind/named.conf.local // // Do any local configuration here // // Consider adding the 1918 zones here, if they are not used in your // organization //include "/etc/bind/zones.rfc1918"; zone "exemplo.org" { type master; file "db_exemplo"; }; zone "100.51.198.in-addr.arpa" { type master; file "db_reverso"; };
Zona direta:
root@ns1:~# cat /var/cache/bind/db_exemplo $TTL 1D @ IN SOA ns1.exemplo.org. root.ns1.exemplo.org. ( 2016061601 ;Serial 3H ;Refresh 1H ;Retry 24H ;Expire 24H ) ;Negative Cache TTL ; @ IN NS ns1.exemplo.org. @ IN MX 5 mail.exemplo.org. ; gateway IN A 198.51.100.254 ns1 IN A 198.51.100.200 ldap IN A 198.51.100.250 mail IN A 198.51.100.240 smtp IN CNAME mail.exemplo.org. imap IN CNAME mail.exemplo.org.
Zona reversa:
root@ns1:~# cat /var/cache/bind/db_reverso $TTL 1D @ IN SOA ns1.exemplo.org. root.ns1.exemplo.org. ( 2016061601 ;Serial 3H ;Refresh 1H ;Retry 24H ;Expire 24H ) ;Negative Cache TTL ; @ IN NS ns1.exemplo.org. ; 254 IN PTR gateway.exemplo.org. 240 IN PTR mail.exemplo.org. 200 IN PTR ns1.exemplo.org.
Modificando o resolv.conf:
root@ns1:~# cat /etc/resolv.conf nameserver 127.0.0.1
root@ns1:~# chattr +i /etc/resolv.conf
Reiniciando o bind e testando a resolução de nomes:
root@ns1:~# systemctl restart bind9
root@ns1:~# host -a exemplo.org Trying "exemplo.org" ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31538 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 2 ;; QUESTION SECTION: ;exemplo.org. IN ANY ;; ANSWER SECTION: exemplo.org. 86400 IN SOA ns1.exemplo.org. root.ns1.exemplo.org. 2016061601 10800 3600 86400 86400 exemplo.org. 86400 IN NS ns1.exemplo.org. exemplo.org. 86400 IN MX 5 mail.exemplo.org. ;; ADDITIONAL SECTION: ns1.exemplo.org. 86400 IN A 198.51.100.200 mail.exemplo.org. 86400 IN A 198.51.100.240