[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Solicitud



2009/6/25 Yacell <yacell@rc.gr.rimed.cu>:
> Saludos listeros, necesito me envien alguna bibliografía de como configurar
> un dns con vistas en debian lenny.
>
> gracias de ante mano.
>
> nota: no tengo acceso a internet.
>
>
> --
> To UNSUBSCRIBE, email to debian-user-spanish-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org
>
>

esta en ingles pero te servira(mas abajo te envio la traduccion de google):

HowTo - Setup DNS (Domain Name Server) using BIND9.

Overview

This HOWTO will assist you in getting a Domain Name Server (DNS) up
and running using BIND9 on Debian Lenny. When setting up a DNS server
it is common practise to use two separate DNS servers for a domain as
you are required to have at least two DNS servers running for DNS to
work correctly. If one breaks, the other can continue to serve your
domain.

However, when I setup my DNS system I did not have the resources on
hand to use two different servers for DNS so the setup below will
configure one server to run both nameservers. It's not an ideal
solution and is definitely not a best practise solution but one can
only work with what you have.

Run BIND in a "chroot" jail, so it is much more difficult for a
compromised bind daemon to damage the operating system or compromise
other services.

In this HOWTO I will use the fictional domain "sampledns.com". The
nameservers will use 192.168.254.1 and 192.168.254.2 as their IP
addresses. Both the domain and namerserver IPs need to be changed to
reflect your server details.

Requirements

A Debian Lenny base installation.
At least two static IP addresses that you can use to setup the
nameserver information.
Root access to your server.

Pre-Installation notes: (You need to be in the root terminal from here
on to the end of this HowTo)

Before proceeding to install, update the necessary packages in Debian
with these commands.

Code: Select all
    apt-get update


and

Code: Select all
    apt-get upgrade



Installing lsb-base and BIND9

To continue we need some Debian building tools since we are going to
download source packages:

Code: Select all
    apt-get install devscripts


The next two steps were put into 2 seperate code windows to shorten
the HowTo a bit since it's rather lenghy. Each command should be run
on a seperate line if not only for the simple reason you can see and
deal with any errors that may be presented without having to go back
and search logs.

BIND9 depends on lsb-base: (Syntax explanation: the -y tells apt to
say yes to all questions, build-dep installs all packages required for
-packageX- from the repository and with -b the source gets built
straight away.)

Code: Select all
    mkdir /usr/local/lsb-base/
    cd /usr/local/lsb-base/
    apt-get -y build-dep lsb-base
    apt-get source lsb-base -b
    dpkg -i lsb-base*.deb


Next is BIND9:

Code: Select all
    mkdir /usr/local/bind9
    cd /usr/local/bind9
    apt-get -y build-dep bind9
    apt-get source bind9 -b
    dpkg -i *.deb


Configure the Master DNS Server

First we need to stop BIND9:

Code: Select all
    /etc/init.d/bind9 stop


In order to chroot bind we need to set an option in /etc/default/bind9.

Locate this in /etc/default/bind9:

Code: Select all
    vim /etc/default/bind9


OPTIONS="-u bind"
Replace it with this:

Code: Select all
    OPTIONS="-u bind -t /var/lib/named"


It will now run as user 'bind' chrooted in '/var/lib/named'.
These steps are required for the chroot jail: (Recommend running each
command on a seperate line)

Code: Select all
    mkdir -p /var/lib/named/etc
    mkdir /var/lib/named/dev
    mkdir -p /var/lib/named/var/cache/bind
    mkdir -p /var/lib/named/var/run/bind/run
    mv /etc/bind /var/lib/named/etc
    ln -s /var/lib/named/etc/bind /etc/bind
    mknod /var/lib/named/dev/null c 1 3
    mknod /var/lib/named/dev/random c 1 8
    chmod 666 /var/lib/named/dev/*
    chown -R bind:bind /var/lib/named/var/*
    chown -R bind:bind /var/lib/named/etc/bind


Bind now has its own dir with space for .pid files and config files.
In order to keep things clear we made a symlink back to /etc/.

NOTE: In this next step i ran into a problem where sysklogd was not
installed for some reason on one the systems i installed the DNS on.
To Fix:

Code: Select all
    apt-get install sysklogd


it will either tell you that you have the latest version or install it
with dependencies.

Now edit /etc/init.d/sysklogd to allow logging of bind activity.

Code: Select all
    vim /etc/init.d/sysklogd


Replace this:
SYSLOGD=""

With this:

Code: Select all
    SYSLOGD="-a /var/lib/named/dev/log"


Now restart sysklogd and BIND9:

Code: Select all
    /etc/init.d/sysklogd restart


Code: Select all
    /etc/init.d/bind9 start


And test:
ping http://www.google.com (NOTE: to stop the ping outputs hit the
ctrl + c key, we do not want to packet flood google)

If you get a reply, then your DNS master server is working and ready
to use. To complete and use the sampledns.com domain with your new
master server. (IMPORTANT: Remember to replace sampledns.com and
192.168.254.1 with your domain information)

Create the zone files:

Start with creating the directory where you will store the zone file.

Code: Select all
    mkdir /etc/bind/zones/master/


Now create the zones file: (This file contains all information about the domain)

Code: Select all
    vim /etc/bind/zones/master/sampledns.com.db


Add the following (NOTE:replacing sampledns.com and 192.168.254.1 with
your own details):

Code: Select all
    ;
    ; BIND data file for sampledns.com
    ;
    $TTL    604800
    @       IN      SOA     sampledns.com. info.sampledns.com. (
                                2009051501         ; Serial
                                      7200         ; Refresh
                                       120         ; Retry
                                   2419200         ; Expire
                                    604800)        ; Default TTL
    ;
    @       IN        NS    ns1.sampledns.com.
    @       IN        NS    ns2.sampledns.com.
    sampledns.com.    IN    MX      10      mail.sampledns.com.
    sampledns.com.    IN    A       192.168.254.1
    www                     IN      CNAME   sampledns.com.
    mail                    IN      A       192.168.254.1
    ftp                     IN      CNAME   sampledns.com.
    sampledns.com.          IN      TXT     "v=spf1 ip4:192.168.254.1 a mx ~all"
    mail                    IN      TXT     "v=spf1 a -all"


Here we have created a DNS zone file with both nameservers as well as
records for the mail and ftp server for the domain sampledns.com.
Trying to go into more detail about what each item reflects above is
beyond the scope of this HOWTO and you should do your own research
into what each item means.

In South Africa registering domain names with the .co.za extension
requires that Reverse DNS (RDNS) is setup correctly. Other TLD's don't
necessarily require RDNS but either way it's good practise to setup
RDNS for your DNS server so we'll do so now.

Create a new file called 192.168.254.rev which follows the convention
of the first three IP ranges in your IP address:

Code: Select all
    vim /etc/bind/zones/master/192.168.254.rev


Add the following: (NOTE:replacing ns1.sampledns.com,
info.sampledns.com and ns2.sampledns.com with your own details):

Code: Select all
    $TTL 1d ;
    $ORIGIN 254.168.192.IN-ADDR.ARPA.
    @       IN      SOA     ns1.sampledns.com.   info.sampledns.com. (
                                           2009051501
                                           7200
                                           120
                                           2419200
                                           604800
    )
            IN      NS      ns1.sampledns.com.
            IN      NS      ns2.sampledns.com.
    1       IN      PTR     ns1.sampledns.com.
    2       IN      PTR     ns2.sampledns.com.


The reverse lookup files are almost identical to the domain zone files
with only minor changes. The first section of this file is exactly the
same as the first section of the domain zone file. The bottom section
is where it is different. This time we are listing the last part of
the IP address first and then the hostname last.

There are 2 IMPORTANT things you must observe here. You have to use
the fully qualified domain name here and you must put a "." at the end
of it. These 2 things are important to the file and weird things
happen if you do not do it exactaly this way.

You must also change the $ORIGIN section at the top of the RDNS file
to reflect the reverse IP address of your server. In this sample our
IP address ranges are 192.168.254.1/2 and the reverse of this would be
254.168.192.IN-ADDR.ARPA. In the PTR records at the bottom we assign
the final IP range to reflect our two nameservers - i.e. 1 & 2.

Making sure everything is OK-

Now that we have created both zone and reverse files. Now we need to
check that our main zone file is good to go. BIND9 breaks very easily
so it's best to run this check before committing your changes.

Code: Select all
    cd /etc/bind/zones/master/


Then run:

Code: Select all
    named-checkzone sampledns.com sampledns.com.db


You should get an OK status when doing this. If not you need to double
check your zone file and make changes until you get an OK status.

Adding zone files to BIND9
We now need to add the zone file data to the named.conf.local file:

Code: Select all
    vim /etc/bind/named.conf.local


And add the following to the file: (Replacing sampledns.com with your details)

Code: Select all
    zone "sampledns.com" {
           type master;
           file "/etc/bind/zones/master/sampledns.com.db";
    };

    zone "254.168.192.IN-ADDR.ARPA" {
           type master;
           file "/etc/bind/zones/master/192.168.254.rev";
    };


Testing

We can now restart bind and check if it works: (don't forget to
replace ns1.sampledns.com with your details)
/etc/init.d/bind9 restart
ping ns1.sampledns.com

This should bring bring up a ping result resolving to 192.168.254.1

Try another test:
nslookup ns1.sampledns.com

Should give you 192.168.254.1

Finally run this one:
dig @localhost sampledns.com

If all is OK then you'll be presented with the zone file information.

At this point you now have a working and usable DNS server.

Troubleshooting

If you're wondering why updates to the zone file on your master seem
to fail, check the serial number inside the zone file. Each time you
make a change to the zone file you will need to increase the Serial
number in the zone file to ensure that your latest changes are
updated.

The serial number is setup and constructed as follows:
2009051501 = (2007)(05)(15)(01)
First 4 digits of the serial indicate the year - i.e. 2009
Next 2 digits of the serial indicate the month - i.e. 05 (May)
Next 2 digits of the serial indicate the date - i.e. 15
The last 2 digits of the serial indicate the revision number for that
day - i.e. 01

If you are updating your Serial number but your changes are not being
reflected I suggest that you reload your BIND data by executing the
following command in a Linux shell:

Code: Select all
    rndc reload



If you are running BIND on two different servers you will need to
install ntpdate on both servers to ensure that zone transfers happen
correctly. Both master and slave servers need to have the exact same
time setting for zone transfers to take place:
apt-get -y install ntpdate


Esta es la traduccion de google:

HowTo - Configuración de DNS (Domain Name Server) utilizando bind9.

Postby Deja-Vu »2009-05-15 21:13
Descripción general

Esta guía le ayudará a conseguir un servidor de nombres de dominio
(DNS) en funcionamiento utilizando bind9 en Debian Lenny. Al
configurar un servidor DNS que es práctica común utilizar dos
servidores DNS de un dominio que se le exige tener un mínimo de dos
servidores DNS para el funcionamiento de DNS para funcionar
correctamente. Si una se rompe, la otra puede continuar sirviendo a su
dominio.

Sin embargo, cuando la configuración DNS de mi sistema no tenía los
recursos a mano para usar dos diferentes servidores de DNS de manera
que la configuración de abajo configurar un servidor que ejecute ambos
nombres. No es una solución ideal y no es la mejor solución práctica,
pero sólo puede trabajar con lo que tienes.

Ejecutar BIND en un "chroot" la cárcel, por lo que es mucho más
difícil para un demonio comprometida obligar a los daños del sistema
operativo o de compromiso de otros servicios.

En esta guía voy a utilizar el dominio ficticio "sampledns.com". El
uso de nombres de 192.168.254.1 y 192.168.254.2 como sus direcciones
IP. Tanto el dominio y direcciones IP namerserver necesitan ser
modificados para reflejar los detalles de su servidor.

Requisitos

Una base de instalación de Debian Lenny.
Al menos dos direcciones IP que puede utilizar para configurar la
información del servidor de nombres.
Acceso de root a su servidor.

Preinstalación de notas: (Es necesario estar en la raíz de terminales
de aquí a finales de este HowTo)

Antes de proceder a instalar, actualizar los paquetes necesarios en
Debian con estos comandos.

Code: Select all
     apt-get update


y

Código: Seleccionar todos
     apt-get upgrade



Instalación lsb-base y bind9

Para continuar, necesitamos algunas herramientas de Debian, ya que se
van a descargar los paquetes fuente:

Código: Seleccionar todos
     apt-get install devscripts


Los dos pasos siguientes se pusieron en 2 ventanas de código separado
para acortar el HowTo un poco ya que es más bien lenghy. Cada comando
debe ejecutarse en una línea separada, si no sólo por la simple razón
de que puede ver y hacer frente a los errores que pueden presentarse
sin tener que volver atrás y los registros de búsqueda.

Bind9 depende de lsb-base: (Sintaxis de explicación:-y le dice a la
tendencia a decir que sí a todas las preguntas, la acumulación de dep
instala todos los paquetes necesarios para la packageX-desde el
repositorio y con b-se construyó la fuente de inmediato.)

Código: Seleccionar todos
     mkdir / usr / local / lsb-base /
     cd / usr / local / lsb-base /
     apt-get-y construir-dep lsb-base
     apt-get source lsb-base-b
     dpkg-i lsb-base *. deb


A continuación se bind9:

Código: Seleccionar todos
     mkdir / usr/local/bind9
     cd / usr/local/bind9
     apt-get-y construir-dep bind9
     apt-get source bind9-b
     dpkg-i *. deb


Configurar el servidor DNS principal

En primer lugar tenemos que dejar de bind9:

Código: Seleccionar todos
     / etc/init.d/bind9 parada


Con el fin de obligar chroot es necesario establecer una opción en /
etc/default/bind9.

Busque en / etc/default/bind9:

Código: Seleccionar todos
     vim / etc/default/bind9


OPCIONES = "-u bind"
Sustituirla por la siguiente:

Código: Seleccionar todos
     OPCIONES = "-u bind-t / var / lib / named"


Que ahora se ejecutan como usuario 'obligar' chroot en '/ var / lib / named ".
Estos pasos son necesarios para la cárcel chroot: (Recomendar
funcionamiento de cada comando en una línea separada)

Código: Seleccionar todos
     mkdir-p / var / lib / named / etc
     mkdir / var / lib / named / dev
     mkdir-p / var / lib / named / var / cache / bind
     mkdir-p / var / lib / named / var / run / bind / run
     mv / etc / bind / var / lib / named / etc
     ln-s / var / lib / named / etc / bind / etc / bind
     mknod / var / lib / named / dev / null c 1 3
     mknod / var / lib / named / dev / random c 1 8
     chmod 666 / var / lib / named / dev / *
     chown-R vinculará: bind / var / lib / named / var / *
     chown-R vinculará: bind / var / lib / named / etc / bind


Obligar ahora tiene su propio espacio de dir. Pid archivos y ficheros
de configuración. A fin de mantener las cosas claras que hicimos de
nuevo a un enlace simbólico / etc /.

NOTA: En este paso siguiente me encontré con un problema en el que
sysklogd no se ha instalado, por alguna razón, en uno de los sistemas
de i instalado en el DNS.
Para solucionarlo:

Código: Seleccionar todos
     apt-get install sysklogd


ya sea que te dicen que tienes la última versión o instalarlo con las
dependencias.

Ahora edite / etc / init.d / sysklogd para permitir la tala de obligar
a la actividad.

Código: Seleccionar todos
     vim / etc / init.d / sysklogd


Reemplace esto:
Syslogd = ""

Con esto:

Código: Seleccionar todos
     Syslogd = "-a / var / lib / named / dev / log"


Ahora reinicie sysklogd y bind9:

Código: Seleccionar todos
     / etc / init.d / sysklogd reiniciar


Código: Seleccionar todos
     / etc/init.d/bind9 inicio


Y la prueba:
ping http://www.google.com (NOTA: para poner fin a la producción de
ping golpear la tecla Ctrl + C, no queremos inundación de paquetes de
google)

Si obtiene una respuesta, entonces su servidor DNS maestro está
trabajando y listas para usar. Para completar y utilizar el dominio
sampledns.com con su nuevo servidor maestro. (IMPORTANTE: Recuerde que
debe sustituir sampledns.com 192.168.254.1 y con su información de
dominio)

Crear la zona de archivos:

Comienza con la creación del directorio donde se almacenará el archivo de zona.

Código: Seleccionar todos
     mkdir / etc / bind / zonas / master /


Crear las zonas de archivo: (Este archivo contiene toda la información
sobre el dominio)

Código: Seleccionar todos
     vim / etc / bind / zonas / maestro / sampledns.com.db


Añadir las siguientes (NOTA: sustituir sampledns.com 192.168.254.1 y
con sus propios detalles):

Código: Seleccionar todos
     ;
     ; Archivo de datos de BIND para sampledns.com
     ;
     $ TTL 604800
     @ IN SOA sampledns.com. info.sampledns.com. (
                                 2009051501; serie
                                       7200; Actualizar
                                        120; Reintentar
                                    2419200; Vence
                                     604800); TTL predeterminado
     ;
     @ IN NS ns1.sampledns.com.
     @ IN NS ns2.sampledns.com.
     sampledns.com. EN MX 10 mail.sampledns.com.
     sampledns.com. EN UN 192.168.254.1
     www IN CNAME sampledns.com.
     correo en un 192.168.254.1
     ftp IN CNAME sampledns.com.
     sampledns.com. EN TXT "v = spf1 ip4: 192.168.254.1 un mx ~ todos"
     correo electrónico en formato TXT "v = spf1 un todo"


Aquí hemos creado una zona DNS de nombres de archivo con los
registros, así como para el correo y el servidor ftp para el dominio
sampledns.com. Tratando de entrar en más detalles acerca de cada tema
refleja lo que es más allá del alcance de esta guía y que debe hacer
su propia investigación en lo que cada uno de los puntos medios.

En Sudáfrica, el registro de nombres de dominio con la extensión.
Co.za extensión que requiere DNS invertida (RDNS) está configurada
correctamente. Otros TLD no necesariamente requieren RDNS pero de
cualquier manera es bueno practicar RDNS para configurar el servidor
DNS por lo que haremos ahora.

Crear un nuevo archivo llamado 192.168.254.rev que se ajusta a la
convención de los tres primeros rangos de IP en su dirección IP:

Código: Seleccionar todos
     vim / etc/bind/zones/master/192.168.254.rev


Añadir el texto siguiente: (NOTA: sustituir ns1.sampledns.com,
info.sampledns.com ns2.sampledns.com y con sus propios detalles):

Código: Seleccionar todos
     $ TTL 1d;
     $ ORIGIN 254.168.192.IN-ADDR.ARPA.
     @ IN SOA ns1.sampledns.com. info.sampledns.com. (
                                            2009051501
                                            7200
                                            120
                                            2419200
                                            604800
     )
             IN NS ns1.sampledns.com.
             IN NS ns2.sampledns.com.
     1 IN PTR ns1.sampledns.com.
     2 IN PTR ns2.sampledns.com.


La búsqueda inversa archivos son casi idénticos a los archivos de zona
del dominio con sólo cambios menores. La primera sección de este
archivo es exactamente la misma que la primera sección del archivo de
zona del dominio. La sección inferior es donde es diferente. Esta vez
se lista la última parte de la dirección IP y, a continuación, el
nombre de host en último lugar.

Hay 2 cosas importantes que debemos observar aquí. Usted tiene que
usar el nombre de dominio completo aquí, y debe poner un "." al final
de la misma. Estas 2 cosas son importantes para el archivo y extraños
que las cosas sucedan, si no lo haces exactaly de esta manera.

También deberá cambiar el $ ORIGIN sección en la parte superior de la
RDNS archivo para reflejar la inversa dirección IP de su servidor. En
esta muestra nuestra dirección IP de los intervalos se 192.168.254.1 /
2 y el reverso de esta situación sería 254.168.192.IN-ADDR.ARPA. En
los registros PTR en la parte inferior le asignamos el último rango de
direcciones IP a fin de reflejar los dos nombres - es decir, 1 y 2.

Asegurarse de que todo está OK

Ahora que hemos creado la zona y revertir los archivos. Ahora tenemos
que comprobar que nuestro principal archivo de zona es buena para ir.
Bind9 rompe muy fácilmente por lo que es mejor para ejecutar esta
comprobación antes de los cambios.

Código: Seleccionar todos
     cd / etc / bind / zonas / master /


A continuación, ejecute:

Código: Seleccionar todos
     named checkzone sampledns.com sampledns.com.db


Usted debe obtener un OK al estado haciendo esto. Si no es necesario
comprobar su archivo de zona y hacer cambios hasta que llegue un
estado en Aceptar.

Adición de archivos de zona a bind9
Ahora tenemos que añadir la zona de archivos de datos a la
named.conf.local el archivo:

Código: Seleccionar todos
     vim / etc / bind / named.conf.local


Y añadir lo siguiente al archivo: (Sustitución sampledns.com con sus datos)

Código: Seleccionar todos
     zona "sampledns.com" (
            type master;
            archivo "/ etc / bind / zonas / maestro / sampledns.com.db";
     );

     zona "254.168.192.IN-ADDR.ARPA" (
            type master;
            archivo "/ etc/bind/zones/master/192.168.254.rev";
     );


Pruebas

Ahora podemos obligar a reiniciar y comprobar si funciona: (no se
olvide de reemplazar ns1.sampledns.com con sus datos)
/ etc/init.d/bind9 reiniciar
ping ns1.sampledns.com

Esto debe llevar a lograr una solución al resultado de ping 192.168.254.1

Pruebe con otra prueba:
nslookup ns1.sampledns.com

Debe darle 192.168.254.1

Ejecutar este último uno:
dig @ localhost sampledns.com

Si todo está bien entonces se le presentó con la zona de información de archivo.

En este punto, ahora tiene un servidor DNS y utilizables.

Solución de problemas

Si usted se pregunta por qué las actualizaciones del archivo de zona
en su maestro parecen no, marque el número de serie en el interior de
la zona de archivo. Cada vez que realizar un cambio en el archivo de
zona tendrá que aumentar el número de serie en el archivo de zona para
asegurarse de que sus últimos cambios se actualizan.

El número de serie es la configuración y construido de la siguiente manera:
2009051501 = (2007) (05) (15) (01)
Los primeros 4 dígitos de la serie indican el año - es decir, 2009
Siguiente 2 dígitos de la serie indican el mes - es decir, 05 (de mayo)
Siguiente 2 dígitos de la serie indica la fecha - es decir, 15
Los 2 últimos dígitos de la serie indican el número de revisión de ese
día - es decir, 01

Si está actualizando su número de serie, pero los cambios no se
reflejan sugiero que volver a cargar sus datos de BIND ejecutando el
siguiente comando en una shell de Linux:

Código: Seleccionar todos
     rndc recarga



Si está corriendo BIND en dos diferentes servidores tendrá que
instalar ntpdate en ambos servidores para garantizar que las
transferencias de zona suceder correctamente. Ambos servidores maestro
y esclavo deben tener exactamente el mismo tiempo para las
transferencias de zona a tener lugar:
apt-get-y ntpdate

-- 
"It is human nature to think wisely and act in an absurd fashion."

"Todo el desorden del mundo proviene de las profesiones mal o
mediocremente servidas"


Reply to: