Instalación del servidor DHCP en Linux Redhat

  • Iniciador del tema Iniciador del tema Daxtrox
  • Fecha de inicio Fecha de inicio

Daxtrox

Usuario Habitual nvl.3 ★
12 Abr 2009
12.016
13
187
iquique
Instalación del servidor DHCP en Linux Redhat


Descargar e instalar el paquete DHCP

Antes de instalar el paquete, revisamos que el servidor dhcp no haya sido instalado anteriormente, tecleando el comando:

Código:
root:~# ntsysv

Si aparece instalado lo activamos, dentro del comando ntsysv o tecleando lo siguiente;

Código:
root:~# chkconfig dhcpd on

De lo contrario, en Redhat Enterprise 5 buscamos el paquete dhcp-3.0.5-3.el5.i386.rpm y lo instalamos:

Código:
root:~# rpm -ivh dhcp-3.0.5-3.el5.i386.rpm


Configuración del servicio DHCP en Linux Redhat Enterprise

Para configurar el servidor de asignacion dinamica de direcciones IP editamos el archivo /etc/dhcp*/dhcpd.conf 0 /etc/dhcpd.conf (dependiendo de la version). De no existir este archivo, la instalacion crea un archivo de configuracion de ejemplo en /usr/share/doc/dhcp-<version-number>/dhcpd.conf.sample.

Ahora debemos sacar una copia de este archivo para poder trabajar en nuestra configuración:

Código:
root:~# cp /usr/share/doc/dhcp-3.0pl1/dhcpd.conf.sample /etc/dhcpd.conf

Un rápido vistazo al archivo de configuración nos muestra lo siguiente:

Código:
ddns-update-style interim
ignore client-updates

subnet 192.168.1.0 netmask 255.255.255.0 {

   # The range of IP addresses the server
   # will issue to DHCP enabled PC clients
   # booting up on the network

   range 192.168.1.201 192.168.1.220;

   # Set the amount of time in seconds that
   # a client may keep the IP address

  default-lease-time 86400;
  max-lease-time 86400;

   # Set the default gateway to be used by
   # the PC clients

   option routers 192.168.1.1;
   # Don't forward DHCP requests from this
   # NIC interface to any other NIC
   # interfaces

   option ip-forwarding off;

   # Set the broadcast address and subnet mask
   # to be used by the DHCP clients

  option broadcast-address 192.168.1.255;
  option subnet-mask 255.255.255.0;

   # Set the NTP server to be used by the
   # DHCP clients

  option ntp-servers 192.168.1.100;

   # Set the DNS server to be used by the
   # DHCP clients

  option domain-name-servers 192.168.1.100;

   # If you specify a WINS server for your Windows clients,
   # you need to include the following option in the dhcpd.conf file:

  option netbios-name-servers 192.168.1.100;

   # You can also assign specific IP addresses based on the clients'
   # ethernet MAC address as follows (Host's name is "laser-printer":

  host laser-printer {
      hardware ethernet 08:00:2b:4c:59:23;
     fixed-address 192.168.1.222;
   }
}
#
# List an unused interface here
#
subnet 192.168.2.0 netmask 255.255.255.0 {
}

En mi versión de producción utilizo algo como lo siguiente, lo cual he comentado o borrado todo el contenido para agregar al final del archivo de configuración:

Código:
option domain-name              "prueba.cl";
option domain-name-servers 192.168.1.10;
option netbios-name-servers 192.168.1.11;
default-lease-time              600;
max-lease-time                  7200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
option broadcast-address 192.168.1.255;
option routers          192.168.1.1;
option subnet-mask      255.255.255.0;
host jefea { #Nombre en la red de la máquina de windows
option host-name "jagencia.bancoreformador.com"; #Opcional
hardware ethernet 00:E0:7D:74:C1:73; #Direccion MAC de la PC.
fixed-address 192.168.1.50; #Direccion IP con la cual va a trabajar la PC.
}
host servidor_archivos {
option host-name "archivos.prueba.cl";
hardware ethernet 00:A1:DD:74:C3:F2;
fixed-address 192.168.1.60;
}
}

Luego de editar, guardamos la configuracion y tecleamos (siempre como root);

Código:
root:~# service dhcpd start
root:~# service dhcpd stop
root:~# service dhcpd restart

Revisamos que el servicio este siendo ejecutado en el sistema operativo, tecleando

Código:
root:~# pgrep dhcpd
11629 #Numero de proceso pid.
Revisar la bitacora del servidor dhcpd, tecleando
root:~# tail -f /var/log/syslog

::portalnet::