Servicios de nombres
1.
Instalación de BIND (Berkeley Internet Naming Daemon)
FreeBSD
6.2 ofrece soporte para el programa BIND, el cual es la
implementación del protocolo DNS mayormente utilizada en el
mundo. BIND forma parte de una instalación estándar de
FreeBSD, por lo tanto no es necesaria su instalación. Se puede
verificar si el paquete bind está
instalado con el siguiente comando:
#
pkg_info | grep bind
En
caso de que BIND no esté instalado, se puede buscar su
disponibilidad en los Ports:
#
cd /usr/ports/
#
make search name=bind9
Port: bind9-9.3.2.1
Path: /usr/ports/dns/bind9
Info: Completely new version of the BIND DNS suite with updated DNSSEC
Maint: DougB@FreeBSD.org
B-deps:
R-deps:
WWW: http://www.isc.org/index.pl?/sw/bind/bind9.3.php
Para
instalar el port bind9:
#
cd /usr/ports/dns/bind9
#
make install
Para
habilitar el servicio bind9, editar el archivo /etc/rc.conf
y añadir la siguiente línea:
named_enable=”YES”
Para
iniciar, parar o reiniciar el servicio:
/etc/rc.d/named
{start, stop, restart}
Los
archivos de configuración se encuentran en el directorio /etc/namedb.
2.
Configuración de DNS de reenvío
Para
configurar el servicio bind9
para reenviar peticiones no resueltas a otros servidores DNS, editar
el archivo /etc/namedb/named.conf de la
siguiente manera (las líneas en negrita han sido agregadas o
editadas):
//
$FreeBSD: src/etc/namedb/named.conf,v 1.21.2.1 2005/09/10 08:27:27
dougb Exp $
//
//
Refer to the named.conf(5) and named(8) man pages, and the
documentation
//
in /usr/share/doc/bind9 for more details.
//
//
If you are going to set up an authoritative server, make sure you
//
understand the hairy details of how DNS works. Even with
//
simple mistakes, you can break connectivity for affected parties,
//
or cause huge amounts of useless Internet traffic.
options
{
directory "/etc/namedb";
pid-file "/var/run/named/pid";
dump-file "/var/dump/named_dump.db";
statistics-file
"/var/stats/named.stats";
//
If named is being used only as a local resolver, this is a safe
default.
//
For named to be accessible to the network, comment this option,
specify
//
the proper IP address, or delete this option.
listen-on {
127.0.0.1;
192.168.10.10;
};
//
If you have IPv6 enabled on this system, uncomment this option for
//
use as a local resolver. To give access to the network, specify
//
an IPv6 address, or the keyword "any".
// listen-on-v6 { ::1; };
//
In addition to the "forwarders" clause, you can force your
name
//
server to never initiate queries of its own, but always ask its
//
forwarders only, by enabling the following line:
//
// forward only;
//
If you've got a DNS server around at your upstream provider, enter
//
its IP address here, and enable the line below. This will make you
//
benefit from its cache, thus reduce overall DNS traffic in the
Internet.
forwarders
{
192.168.10.254;
};
/*
*
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 versions 8 and later
*
use a pseudo-random unprivileged UDP port by default.
*/
//
query-source address * port 53;
};
//
If you enable a local name server, don't forget to enter 127.0.0.1
//
first in your /etc/resolv.conf so this server will be queried.
//
Also, make sure to enable it in /etc/rc.conf.
zone
"." {
type
hint;
file
"named.root";
};
zone
"0.0.127.IN-ADDR.ARPA" {
type
master;
file
"master/localhost.rev";
};
//
RFC 3152
zone
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"
{
type
master;
file
"master/localhost-v6.rev";
};
//
NB: Do not use the IP addresses below, they are faked, and only
//
serve demonstration/documentation purposes!
//
//
Example slave zone config entries. It can be convenient to become
//
a slave at least for the zone your own domain is in. Ask
//
your network administrator for the IP address of the responsible
//
primary.
//
//
Never forget to include the reverse lookup (IN-ADDR.ARPA) zone!
//
(This is named after the first bytes of the IP address, in reverse
//
order, with ".IN-ADDR.ARPA" appended.)
//
//
Before starting to set up a primary zone, make sure you fully
//
understand how DNS and BIND works. There are sometimes
//
non-obvious pitfalls. Setting up a slave zone is simpler.
//
//
NB: Don't blindly enable the examples below. :-) Use actual names
//
and addresses instead.
/*
An example master zone
zone
"example.net" {
type
master;
file
"master/example.net";
};
*/
/*
An example dynamic zone
key
"exampleorgkey" {
algorithm
hmac-md5;
secret
"sf87HJqjkqh8ac87a02lla==";
};
zone
"example.org" {
type
master;
allow-update
{
key
"exampleorgkey";
};
file
"dynamic/example.org";
};
*/
/*
Examples of forward and reverse slave zones
zone
"example.com" {
type
slave;
file
"slave/example.com";
masters
{
192.168.1.1;
};
};
zone
"1.168.192.in-addr.arpa" {
type
slave;
file
"slave/1.168.192.in-addr.arpa";
masters
{
192.168.1.1;
};
};
*/
Básicamente,
se modifica la siguiente línea con la dirección ip del
servidor:
listen-on
{
127.0.0.1;
192.168.10.10;
};
También
se modifica el siguiente fragmento con la dirección ip del
servidor DNS reenviador:
forwarders
{
192.168.10.254;
};
Acto
seguido, es necesario modificar el archivo /etc/resolv.conf y
añadir en primer lugar una entrada de servidor de nombres con
la ip del servidor.
nameserver
192.168.10.10
Para
hacer efectivos los cambios, reiniciar el servicio DNS:
#
/etc/rc.d/named restart
3.
Configuración de clientes
Para
configurar la dirección del servidor DNS en un cliente es
necesario editar el archivo /etc/resolv.conf. Ejemplo:
nameserver
192.168.10.254
Un
cliente puede realizar una consulta mediante el comando dig.
Ejemplo:
$
dig www.yahoo.com
;
<<>> DiG 9.3.2-P1 <<>> www.yahoo.com
;;
global options: printcmd
;;
Got answer:
;;
->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12839
;;
flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 9, ADDITIONAL: 0
;;
QUESTION SECTION:
;www.yahoo.com. IN A
;;
ANSWER SECTION:
www.yahoo.com. 60 IN CNAME www.yahoo-ht2.akadns.net.
www.yahoo-ht2.akadns.net.
60 IN A 209.73.186.238
;;
AUTHORITY SECTION:
akadns.net. 172799 IN NS eur4.akadns.net.
akadns.net. 172799 IN NS eur8.akadns.net.
akadns.net. 172799 IN NS usw5.akadns.net.
akadns.net. 172799 IN NS asia4.akadns.net.
akadns.net. 172799 IN NS asia9.akadns.net.
akadns.net. 172799 IN NS za.akadns.org.
akadns.net. 172799 IN NS zb.akadns.org.
akadns.net. 172799 IN NS zc.akadns.org.
akadns.net. 172799 IN NS zd.akadns.org.
;;
Query time: 1855 msec
;;
SERVER: 192.168.10.254#53(192.168.10.254)
;;
WHEN: Sun Oct 15 14:53:18 2006
;;
MSG SIZE rcvd: 260
4.
Configuración de zonas
Por
defecto, bind utiliza el puerto 53 tcp y udp. Se
puede verificar que el servidor esté escuchando a través
de los puertos con el siguiente comando:
#
sockstat | grep 53
bind named 1589 20 udp4 192.168.10.10:53 *:*
bind named 1589 21 tcp4 192.168.10.10:53 *:*
bind named 1589 24 tcp4 127.0.0.1:953 *:*
bind named 1589 25 tcp6 ::1:953 *:*
Para
configurar zonas en el servidor DNS, es necesario editar el archivo /etc/namedb/named.conf.
A continuación se provee un
ejemplo de archivo de configuración named.conf, en el
cual se definen zonas directas e inversas para un dominio llamado freebsd.internal (las
partes
en negrita fueron editadas o agregadas).
//
$FreeBSD: src/etc/namedb/named.conf,v 1.21.2.1 2005/09/10 08:27:27
dougb Exp $
//
//
Refer to the named.conf(5) and named(8) man pages, and the
documentation
//
in /usr/share/doc/bind9 for more details.
//
//
If you are going to set up an authoritative server, make sure you
//
understand the hairy details of how DNS works. Even with
//
simple mistakes, you can break connectivity for affected parties,
//
or cause huge amounts of useless Internet traffic.
options
{
directory "/etc/namedb";
pid-file "/var/run/named/pid";
dump-file "/var/dump/named_dump.db";
statistics-file
"/var/stats/named.stats";
//
If named is being used only as a local resolver, this is a safe
default.
//
For named to be accessible to the network, comment this option,
specify
//
the proper IP address, or delete this option.
listen-on { 192.168.10.10; };
//
If you have IPv6 enabled on this system, uncomment this option for
//
use as a local resolver. To give access to the network, specify
//
an IPv6 address, or the keyword "any".
// listen-on-v6 { ::1; };
//
In addition to the "forwarders" clause, you can force your
name
//
server to never initiate queries of its own, but always ask its
//
forwarders only, by enabling the following line:
//
// forward only;
//
If you've got a DNS server around at your upstream provider, enter
//
its IP address here, and enable the line below. This will make you
//
benefit from its cache, thus reduce overall DNS traffic in the
Internet.
forwarders
{
192.168.10.254;
};
/*
*
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 versions 8 and later
*
use a pseudo-random unprivileged UDP port by default.
*/
//
query-source address * port 53;
};
//
If you enable a local name server, don't forget to enter 127.0.0.1
//
first in your /etc/resolv.conf so this server will be queried.
//
Also, make sure to enable it in /etc/rc.conf.
zone
"." {
type
hint;
file
"named.root";
};
zone
"0.0.127.IN-ADDR.ARPA" {
type
master;
file
"master/localhost.rev";
};
//
RFC 3152
//zone
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"
//{
// type master;
// file "master/localhost-v6.rev";
//};
//
NB: Do not use the IP addresses below, they are faked, and only
//
serve demonstration/documentation purposes!
//
//
Example slave zone config entries. It can be convenient to become
//
a slave at least for the zone your own domain is in. Ask
//
your network administrator for the IP address of the responsible
//
primary.
//
//
Never forget to include the reverse lookup (IN-ADDR.ARPA) zone!
//
(This is named after the first bytes of the IP address, in reverse
//
order, with ".IN-ADDR.ARPA" appended.)
//
//
Before starting to set up a primary zone, make sure you fully
//
understand how DNS and BIND works. There are sometimes
//
non-obvious pitfalls. Setting up a slave zone is simpler.
//
//
NB: Don't blindly enable the examples below. :-) Use actual names
//
and addresses instead.
//
Zona maestra
zone
"freebsd.internal" {
type
master;
file
"master/freebsd.internal";
};
zone
"10.168.192.in-addr.arpa" {
type
master;
file
"master/10.168.192.in-addr.arpa";
};
Básicamente
se agregan las líneas a partir de el comentario “Zona
maestra” con las definiciones de zona directa e inversa para un
dominio freebsd.internal en la red 192.168.10.0.
También se comenta la siguiente sección del archivo de
configuración:
//
RFC 3152
//zone
"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA"
//{
// type master;
// file "master/localhost-v6.rev";
//};
El
siguiente paso es crear el archivo de localhost de zona en
reversa:
#
cd /etc/namedb
#
sh make-localhost
Acto
seguido, crear el archivo de zona directa maestra. Este archivo
deberá ser llamado /etc/namedb/master/freebsd.internal
:
$TTL
604800
@ IN SOA demonio.freebsd.internal.
root.freebsd.internal. (
20061015 ;
Serial
604800 ;
Refresh
86400 ; Retry
2419200 ;
Expire
604800
) ; Negative Cache TTL
;
@ IN NS demonio.freebsd.internal.
@ IN A 192.168.10.10
demonio IN A 192.168.10.10
A
continuación, crear el archivo de zona inversa maestra. Este
archivo deberá ser llamado /etc/named/master/10.168.192.in-addr.arpa:
$TTL
604800
@ IN SOA demonio.freebsd.internal. root.freebsd.internal
(
20061015 ;
serial
604800 ;
refresh
86400 ; retry
2419200 ;
expire
604800
) ; negative cache
;
@ IN NS demonio.freebsd.internal.
10 IN PTR demonio.freebsd.internal.
Una
vez establecidas las zonas y creados los archivos de zona, es
necesario reiniciar el servidor bind para hacer efectivos los
cambios:
#
/etc/rc.d/named restart
Stopping
named.
Starting
named.
Se
puede probar la resolución desde cualquier cliente utilizando dig
o nslookup:
$
dig freebsd.internal
;
<<>> DiG 9.4.0 <<>> freebsd.internal
;;
global options: printcmd
;;
Got answer:
;;
->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25363
;;
flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;;
QUESTION SECTION:
;freebsd.internal. IN A
;;
ANSWER SECTION:
freebsd.internal. 603034 IN A 192.168.10.10
;;
AUTHORITY SECTION:
freebsd.internal. 603034 IN NS demonio.freebsd.internal.
;;
ADDITIONAL SECTION:
demonio.freebsd.internal.
603034 IN A 192.168.10.10
;;
Query time: 2 msec
;;
SERVER: 192.168.10.254#53(192.168.10.254)
;;
WHEN: Fri Aug 10 13:16:49 2007
;;
MSG SIZE rcvd: 88
$
nslookup freebsd.internal
Server: 192.168.10.10
Address: 192.168.10.10#53
Name: freebsd.internal
Address:
192.168.10.10
5. Zonas
de reenvío
En
ocasiones es conveniente configurar zonas de reenvío para
dirigir peticiones DNS directamente a ciertos servidores. Por
ejemplo, si se desea configurar el servidor DNS de la compañía
A para que todas las peticiones DNS de un determinado dominio las
dirija hacia el servidor DNS de la compañía B; es
conveniente crear una zona de reenvío.
Para
configurar una zona de reenvío, editar el archivo /etc/named/named.conf
y añadir en la sección de
zonas la configuración de reenvío. A continuación
se muestra un ejemplo de zona de reenvío de peticiones al
dominio fedora.internal directamente a través del
servidor DNS con la dirección 192.168.10.254:
zone
"fedora.internal" {
type forward;
forwarders {
192.168.10.254;};
};
Previo
Instalación de escritorio GNOME
|
Inicio
|
Siguiente
Implementación de servidor web
|