Mudanças entre as edições de "DNS"
| Linha 83: | Linha 83: | ||
; Nomes de Maquinas | ; Nomes de Maquinas | ||
4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR dns1.exemplo.ifrs.edu.br. | 4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR dns1.exemplo.ifrs.edu.br. | ||
| + | |||
| + | === Views === | ||
| + | Agora é necessário referenciar as zonas criadas no arquivo named.conf.local e colocar estas zonas em views para limitar o acesso interno e externo. | ||
| + | |||
| + | A view "dns_recursivo" é destinado para somente acesso local em uma rede interna, o parâmetro "match-clients", "allow-recursion" e "recursion = no" realizam esta regra. | ||
| + | |||
| + | A view "dns_autoritativo" é destinado para acesso externo onde outros servidores de DNS irão acessar este servidor e realizar o cache o parâmetro "match-clients" e "recursion = no" realizam esta regra. | ||
| + | |||
| + | Arquivo /etc/bind/named.conf.local | ||
| + | |||
| + | acl rede_local { ::1; localhost; 192.0.2.0/24; 2001:0db8::/48; }; | ||
| + | view "dns_recursivo" { | ||
| + | match-clients { rede_local; }; | ||
| + | allow-recursion { rede_local; }; | ||
| + | recursion yes; | ||
| + | zone "exemplo.ifrs.edu.br" { | ||
| + | type master; | ||
| + | allow-transfer { none; }; | ||
| + | allow-update{ none; }; | ||
| + | file "/etc/bind/zonas/exemplo.ifrs.edu.br"; | ||
| + | }; | ||
| + | // Zona reversa IPv4 | ||
| + | zone "91.17.200.in-addr.arpa" { | ||
| + | type master; | ||
| + | allow-transfer { none; }; | ||
| + | allow-update{ none; }; | ||
| + | file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev"; | ||
| + | }; | ||
| + | // Zona reversa IPv6 | ||
| + | zone "0.b.4.2.0.0.0.0.4.0.8.2.ip6.arpa." { | ||
| + | type master; | ||
| + | allow-transfer { none; }; | ||
| + | allow-update{ none; }; | ||
| + | file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev.ipv6"; | ||
| + | }; | ||
| + | zone "." { | ||
| + | type hint; | ||
| + | file "/etc/bind/db.root"; | ||
| + | }; | ||
| + | zone "localhost" { | ||
| + | type master; | ||
| + | file "/etc/bind/db.local"; | ||
| + | }; | ||
| + | zone "127.in-addr.arpa" { | ||
| + | type master; | ||
| + | file "/etc/bind/db.127"; | ||
| + | }; | ||
| + | zone "0.in-addr.arpa" { | ||
| + | type master; | ||
| + | file "/etc/bind/db.0"; | ||
| + | }; | ||
| + | zone "255.in-addr.arpa" { | ||
| + | type master; | ||
| + | file "/etc/bind/db.255"; | ||
| + | }; | ||
| + | }; | ||
| + | view "dns_autoritativo" { | ||
| + | match-clients { any; }; | ||
| + | recursion no; | ||
| + | additional-from-auth no; | ||
| + | additional-from-cache no; | ||
| + | // Zonas exemplo | ||
| + | zone "exemplo.ifrs.edu.br" { | ||
| + | type master; | ||
| + | file "/etc/bind/zonas/exemplo.ifrs.edu.br"; | ||
| + | zone-statistics yes; | ||
| + | }; | ||
| + | // Zona reversa IPv4 | ||
| + | zone "91.17.200.in-addr.arpa" { | ||
| + | type master; | ||
| + | file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev"; | ||
| + | allow-transfer { IP.SERVDOR.SLAVE; }; | ||
| + | allow-update{ none; }; | ||
| + | also-notify { IP.SERVDOR.SLAVE; }; | ||
| + | notify yes; | ||
| + | zone-statistics yes; | ||
| + | }; | ||
| + | // Zona reversa IPv6 | ||
| + | zone "0.b.4.2.0.0.0.0.4.0.8.2.ip6.arpa." { | ||
| + | type master; | ||
| + | file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev.ipv6"; | ||
| + | allow-transfer { IP.SERVDOR.SLAVE; }; | ||
| + | allow-update{ none; }; | ||
| + | also-notify { IP.SERVDOR.SLAVE; }; | ||
| + | notify yes; | ||
| + | zone-statistics yes; | ||
| + | }; | ||
| + | }; | ||
Edição das 19h08min de 11 de abril de 2016
Índice
Servidor de DNS
Neste tutorial será mostrado como montar um servidor de DNS autoritativo e recursivo no mesmo servidor respeitando regras de acesso utilizando views. Também será criada uma zona fictícia exemplo.ifrs.edu.br com sua respectiva zona reversa em IPv4 e IPv6 para receber consultas externas.
Informações iniciais
Domínio: exemplo.ifrs.edu.br
IPv4: 192.0.2.4
IPv6: 2001:0DB8::4
Hostname: dns1.exemplo.ifrs.edu.br
S.O.: Debian 8 (Jessie)
Versão BIND: 9.9.5-9
Instalação do BIND
# apt-get install bind9 -y
Configuração
Editar o arquivo de configuração /etc/bind/named.conf.options
options {
directory "/var/cache/bind";
statistics-file "/var/log/bind/named.stats";
memstatistics-file "/var/log/bind/mem.stats";
dnssec-enable yes;
dnssec-validation auto;
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
version "named";
};
Zona exemplo.ifrs.edu.br
Arquivo /etc/bind/zonas/exemplo.ifrs.edu.br
$TTL 86400
@ IN SOA dns1.exemplo.ifrs.edu.br. admin.exemplo.ifrs.edu.br. (
2016040601 ; Serial
3H ; Refresh
1H ; Retry
1W ; Expire
1D) ; Minimum TTL
; Servidores DNS
@ IN NS dns1.exemplo.ifrs.edu.br.
;
dns1 IN A 192.0.2.4
dns1 IN AAAA 2001:0DB8::4
Zonas reversa IPv4
Arquivo /etc/bind/zonas/exemplo.ifrs.edu.br.rev
;$ORIGIN 2.0.192.in-addr.arpa.
$TTL 86400
@ IN SOA dns1.exemplo.ifrs.edu.br. admin.exemplo.ifrs.edu.br. (
2016030501 ;Serial
3H ; Refresh
1H ; Retry
1W ; Expire
1D) ; Minimum TTL
; Servidores DNS
@ IN NS dns1.exemplo.ifrs.edu.br.
Zonas reversa IPv6
Arquivo /etc/bind/zonas/exemplo.ifrs.edu.br.rev.ipv6
;$ORIGIN 0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
;Bloco IPv6 2001:0DB8::/48
$TTL 86400
@ IN SOA dns1.exemplo.ifrs.edu.br. admin.exemplo.ifrs.edu.br. (
2016032401 ;Serial
3H ; Refresh
1H ; Retry
1W ; Expire
1D) ; Minimum TTL
; Servidores DNS
@ IN NS dns1.exemplo.ifrs.edu.br.
; Nomes de Maquinas
4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR dns1.exemplo.ifrs.edu.br.
Views
Agora é necessário referenciar as zonas criadas no arquivo named.conf.local e colocar estas zonas em views para limitar o acesso interno e externo.
A view "dns_recursivo" é destinado para somente acesso local em uma rede interna, o parâmetro "match-clients", "allow-recursion" e "recursion = no" realizam esta regra.
A view "dns_autoritativo" é destinado para acesso externo onde outros servidores de DNS irão acessar este servidor e realizar o cache o parâmetro "match-clients" e "recursion = no" realizam esta regra.
Arquivo /etc/bind/named.conf.local
acl rede_local { ::1; localhost; 192.0.2.0/24; 2001:0db8::/48; };
view "dns_recursivo" {
match-clients { rede_local; };
allow-recursion { rede_local; };
recursion yes;
zone "exemplo.ifrs.edu.br" {
type master;
allow-transfer { none; };
allow-update{ none; };
file "/etc/bind/zonas/exemplo.ifrs.edu.br";
};
// Zona reversa IPv4
zone "91.17.200.in-addr.arpa" {
type master;
allow-transfer { none; };
allow-update{ none; };
file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev";
};
// Zona reversa IPv6
zone "0.b.4.2.0.0.0.0.4.0.8.2.ip6.arpa." {
type master;
allow-transfer { none; };
allow-update{ none; };
file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev.ipv6";
};
zone "." {
type hint;
file "/etc/bind/db.root";
};
zone "localhost" {
type master;
file "/etc/bind/db.local";
};
zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};
zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};
zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};
};
view "dns_autoritativo" {
match-clients { any; };
recursion no;
additional-from-auth no;
additional-from-cache no;
// Zonas exemplo
zone "exemplo.ifrs.edu.br" {
type master;
file "/etc/bind/zonas/exemplo.ifrs.edu.br";
zone-statistics yes;
};
// Zona reversa IPv4
zone "91.17.200.in-addr.arpa" {
type master;
file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev";
allow-transfer { IP.SERVDOR.SLAVE; };
allow-update{ none; };
also-notify { IP.SERVDOR.SLAVE; };
notify yes;
zone-statistics yes;
};
// Zona reversa IPv6
zone "0.b.4.2.0.0.0.0.4.0.8.2.ip6.arpa." {
type master;
file "/etc/bind/zonas/exemplo.ifrs.edu.br.rev.ipv6";
allow-transfer { IP.SERVDOR.SLAVE; };
allow-update{ none; };
also-notify { IP.SERVDOR.SLAVE; };
notify yes;
zone-statistics yes;
};
};