Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
INSTALACIÓN DE UN
SERVIDOR DNS Y DHCP
DNS Y DHCP 2/6
Una vez iniciado la máquina servidor identificamos el nombre se le ha dado a cada una de las
tarjetas de red que usaremos. Para ello abrimos terminal y ejecutamos el comando ifconfig
dejándolo así:
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet dhcp
auto enp0s8 enp0s9
iface enp0s8 inet static
address 192.168.1.1
netmask 255.255.255.0
iface enp0s9 inet static
address 172.16.1.1
netmask 255.255.255.0
DNS Y DHCP 3/6
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113
// 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 {
10.10.1.1;
};
//=====================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//=====================================================================
dnssec-validation auto;
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};
El problema está en que este archivo está protegido y queremos que no se cambie con cada
reinicio. Para ello vamos a hacer lo siguiente:
DNS Y DHCP 4/6
ddns-update-style none;
default-lease-time 600;
max-lease-time 1000;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.150;
option routers 192.168.1.1;
option domain-name-servers 192.168.1.1;
}
subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.50 172.16.1.80;
option routers 172.16.1.1;
option domain-name-servers 172.16.1.1;
}
DNS Y DHCP 5/6
● Es muy importante indicar en INTERFACES cuáles son las tarjetas por las que se habilita
el DCHP. Hay que indicar cuáles son las nuestras. En mi caso enp0s8 y enp0s9.
Después reiniciamos de nuevo el servidor.
DNS Y DHCP 6/6
● Además vamos a crear el fichero rc.local dentro de la carpeta /etc y escribimos lo
siguiente:
#!/bin/sh -e
# reiniciamos iptables
iptables -F
iptables -t nat -F
iptables -t mangle -F
# aceptamos lo que nos llegue por la red interna
iptables -A FORWARD -i eth1 -j ACCEPT
iptables -A FORWARD -i eth2 -j ACCEPT
#aplicamos NAT a todo lo que salga por eth0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
# también podemos optar por sustituir la linea anterior por
#iptables -t nat -A POSTROUTING -s 172.16.1.0/24 -o eth0 -j MASQUERADE
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
# si NO queremos dar acceso exterior a una interfaz, debemos comentar la
linea anterior que
corresponda
exit 0
Guardamos y reiniciamos toda la máquina. Al ejecutar las máquinas clientes le indicamos la
tarjeta con la red que deseamos que usar y si todo ha ido bien, el servidor DNS y DHCP deberían
de funcionar.