Galera, como todos meus outros artigos digo que isso não é receita de bolo e que eu sei que na internet está cheio de artigos ensinando a montar o mesmo servidor. Mas todos esses artigos da internet ensinam a fazer um ou outro servidor, então resolvi montar os dois e postar minha experiência. E lembrem-se: aprender é fundamental.
Este script foi obtido na internet no site descrito em bibliografia e seu autor está descriminado no próprio script, eu não o testei, mas fica como dica.
###################CAMINHO DA JAULA DO BIND######################
PATH_BIND="/var/lib/named" ############################################################
###################VARIÁVEIS PARA A CONFIGURAÇÃO DAS ZONAS#########
echo -n "Forneça o nome do domínio a ser configurado (dominio.com.br): "
read DOMAIN
echo -n "Forneça a faixa de IP da rede valida (ip/mask EX:10.10.10.0/24): "
read NETWORK_RANGE
echo -n "Forneça o endereço IP do servidor NS1 (ip): "
read NS1_IP
echo -n "Forneça o endereço IP do servidor NS2 (ip): "
read NS2_IP
echo -n "Forneça o endereço IP do servidor MX (ip): "
read MX_IP
echo -n "Forneça o endereço IP do servidor WWW (ip): "
read WWW_IP
######################AJUSTANDO O ARQUIVO /etc/default/bind9############
${CAT} <<EOF > /etc/default/bind9 #/etc/default/bind9
RESOLVCONF=yes
# startup options for the server #OPTIONS="-u bind"
OPTIONS="-u bind -t ${PATH_BIND}"
EOF ##############################################################
// If there is a firewall between you and nameservers you want
// to talk to, you might need to uncomment the query-source
// directive below. Previous versions of BIND always asked
// questions using port 53, but BIND 8.1 and later use an unprivileged
// port by default.
// query-source address * port 53;
// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.
// forwarders {
// 0.0.0.0;
// };
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
#######################AJUSTANDO O ARQUIVO /etc/bind/named.conf.local#######
${MV} ${PATH_BIND}/etc/bind/named.conf ${PATH_BIND}/etc/bind/named.conf.orig
${CAT} <<EOF > ${PATH_BIND}/etc/bind/named.conf
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
include "/etc/bind/named.conf.options";
// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};
// be authoritative for the localhost forward and reverse zones, and for
// broadcast zones as per RFC 1912
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";
};
zone "${DOMAIN}" {
type master;
file "db.${DOMAIN}";
allow-transfer { ${NS2_IP}; };
};
zone "${IP_REVERSE}.in-addr.arpa" {
type master;
file "db.${IP_REVERSE}";
allow-transfer { ${NS2_IP}; };
};
include "/etc/bind/named.conf.local";
EOF #################################################################
###############AJUSTANDO O ARQUIVO /var/lib/named/var/cache/bind/db.dominio.com.br##
${CAT} <<EOF > ${PATH_BIND}/var/cache/bind/db.${DOMAIN}
`echo '$TTL 86400'`
@ IN SOA dns.${DOMAIN}. root.dns.${DOMAIN}. (
`date +%Y%m%d`01 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
3600 ) ; Minimum
;
@ IN NS ${DOMAIN}.
@ IN NS ns1.${DOMAIN}.
@ IN NS ns2.${DOMAIN}.
@ IN MX 0 mail.${DOMAIN}.
;NAME SERVERS
@ IN A ${NS1_IP}
ns1 IN A ${NS1_IP}
ns2 IN A ${NS2_IP}
dns IN A ${NS1_IP}
;MAIL SERVERS
mail IN A ${MX_IP}
imap IN CNAME mail
pop IN CNAME mail
smtp IN CNAME mail
webmail IN CNAME mail
;WEB SERVERS
adm IN A ${WWW_IP}
www IN A ${WWW_IP}
ftp IN CNAME www
dbadmin IN CNAME www
mailadmin IN CNAME www
EOF #####################################################################