Logotipo del grupo GSO

5. Ejemplo de fichero de configuración de DHCP

A continuación se presentarán los archivos de configuración y los scripts de inicio usados en la red de la Unidad de Imagen y en el Laboratorio F1.

5.1. Unidad de Imagen

Archivo de configuración del DHCP: /etc/dhcpd.conf

# dhcpd.conf
#
# Configuración de la red de la Unidad de Imagen.
#
#
# El rango de direcciones 192.168.1.1-10 está reservada
# para los servidores y ordenadores con IP fija.
#

subnet 192.168.1.0 netmask 255.255.255.0 {

  range 192.168.1.11 192.168.1.29;

  option domain-name-servers 192.168.1.1, 193.146.96.2, 193.146.96.3;
  option domain-name "uimagen.iaf";
  option routers 192.168.1.1;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.1.255;

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

  group {

     default-lease-time 604800;
     max-lease-time 691200;

     host apache {
         hardware ethernet 00:10:5a:f1:35:87;
         fixed-address 192.168.1.3;
     }

  }
}

Script de inicio del DHCP: /etc/init.d/dhcp

#! /bin/sh
#
# Script de inicio del servicio DHCP
#

DAEMON="/usr/sbin/dhcpd"
ARGS="eth0"
DHCPDPID=/var/run/dhcpd.pid

test -x ${DAEMON} || exit 0

# Asigna el valor 1 a la variable run_dhcpd para poder arrancar el dhcpd al inicio
# o el valor 0 para desabilitarlo.
run_dhcpd=1

if [ $run_dhcpd = 0 ]; then
  cat <<EOF

EOF
  exit 0
fi

case "$1" in
  start)
    start-stop-daemon --start --quiet --pidfile $DHCPDPID \
      --exec ${DAEMON} -- ${ARGS}
    ;;
  stop)
    start-stop-daemon --stop --quiet --pidfile $DHCPDPID
    ;;
  restart | force-reload)
    start-stop-daemon --stop --quiet --pidfile $DHCPDPID
    sleep 2
    start-stop-daemon --start --quiet --pidfile $DHCPDPID \
      --exec {$DAEMON} -- ${ARGS}
    ;;
  *)
    echo "Usage: /etc/init.d/dhcp {start|stop|restart|force-reload}"
    exit 1
esac

exit 0

5.2. Laboratorio F1

Archivo de configuración del DHCP: /etc/dhcpd.conf

# dhcpd.conf
#
# Configuración de la red del laboratorio F1
#


# RED DE PROYECTOS
#
# El rango 192.168.4.1-19 está reservado para direcciones
# fijas (servidores, por ejemplo).
#
# El rango 192.168.4.20-100 está reservado para equipos
# con ip's dinámicas.
#

subnet 192.168.4.0 netmask 255.255.255.0 {

  range 192.168.4.20 192.168.4.100;

  option domain-name-servers 192.168.4.1, 193.146.96.2, 193.146.96.3;
  option domain-name "sinformaticos.local";
  option routers 192.168.4.1;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.4.255;

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

  group {

      option domain-name "sistemasop.ui";
      default-lease-time 604800;
      max-lease-time 691200;

      host potasio {
          hardware ethernet 00:04:76:0B:D8:C6;
          fixed-address 192.168.4.2;
    }
  }
}

# RED DESMILITARIZADA DE SERVIDORES
#
# El rango 192.168.3.1-19 está reservado para servidores
# fijos.
#
# El rango 192.168.3.20-100 está reservado para equipos
# con ip's dinámicas.
#

subnet 192.168.3.0 netmask 255.255.255.0 {

  range 192.168.3.20 192.168.3.100;

  option domain-name-servers 192.168.3.1, 193.146.96.2, 193.146.96.3;
  option domain-name "sinformaticos.local";
  option routers 192.168.3.1;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.3.255;

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

  group {

      option domain-name "sistemasop.ui";
      default-lease-time 604800;
      max-lease-time 691200;

      host hidrogeno {
          hardware ethernet 00:04:76:0B:D6:F8;
          fixed-address 192.168.3.1 ;
      }

      host litio {
          hardware ethernet 00:04:76:0B:D8:80;
          fixed-address 192.168.3.2;
      }

      host sodio {
          hardware ethernet;
          fixed-address 192.168.3.3;
      }
      host armitage {
          hardware ethernet 08:00:69:0e:97:a7;
          fixed-address 192.168.3.4;
      }

      host switch {
          hardware ethernet 00:30:c1:aa:8b:80;
          fixed-address 192.168.3.10;
     }
  }
}


# RED DE CLIENTES
#
# El rango 192.168.2.1-39 está reservado para equipos
# con ip's fijas.
#
# El rango 192.168.2.40-100 está reservado para equipos
# clientes con ip's dinámicas.
#

subnet 192.168.2.0 netmask 255.255.255.0 {

  range 192.168.2.40 192.168.2.100;

  option domain-name-servers 192.168.2.1, 193.146.96.2, 193.146.96.3;
  option domain-name "sinformaticos.local";
  option routers 192.168.2.1;
  option subnet-mask 255.255.255.0;
  option broadcast-address 192.168.2.255;

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

  group {

      default-lease-time 604800;
      max-lease-time 691200;

      host si-server {
          hardware ethernet 00:04:76:0B:D8:C9;
          fixed-address 192.168.2.4;
      }

      host si-bdc {
          hardware ethernet 00:04:76:0B:D8:DF;
          fixed-address 192.168.2.5;
      }

      host cluster1 {
          hardware ethernet 00:04:76:0B:D8:78;
          fixed-address 192.168.2.11;
          option domain-name "sistemasop.ui";
      }

      host cluster2 {
          hardware ethernet 00:04:76:0B:D8:83;
          fixed-address 192.168.2.12;
          option domain-name "sistemasop.ui";
      }

##
## Configuración para el programa FAI
##

##    host equipo-12 {
##
##      # dhcpd.conf for fai
##      # replace FAISERVER with the name of your install server
##
##      #deny unknown-clients;
##      #option dhcp-max-message-size 2048;
##      #use-host-decl-names on;
##      #always-reply-rfc1048 on;
##
##        option option-170 "hidrogeno:/usr/local/share/fai";   # FAI_LOCATION
##        option option-171 "sysinfo";                         # FAI_ACTION
##        option option-172 "verbose sshd";                    # FAI_FLAGS
##        option root-path "/usr/lib/fai/nfsroot";
##
##            option routers 192.168.2.1;
##            option domain-name "sistemasop.ui";
##          option domain-name-servers 192.168.2.1,193.146.96.2,193.146.96.3;
##          #   option time-servers hidrogeno;
##          #   option ntp-servers time.rrz.uni-koeln.de,time2.rrz.uni-koeln.de;
##            server-name "hidrogeno";
##
##      hardware ethernet 00:04:76:0b:d8:87;
##          filename "/boot/equipo-12";
##            fixed-address 192.168.2.200;
##            option option-171 "sysinfo";    }
  }
}

Script de inicio del DHCP: /etc/init.d/dhcp

#! /bin/sh
#
# Script de inicio del servicio DHCP
#

DAEMON="/usr/sbin/dhcpd"
ARGS="-cf /etc/dhcpd.conf eth1 eth2"
DHCPDPID=/var/run/dhcpd.pid

test -x ${DAEMON} || exit 0

# Asigna el valor 1 a la variable run_dhcpd para poder arrancar el dhcpd al inicio
# o el valor 0 para desabilitarlo.
run_dhcpd=1

if [ $run_dhcpd = 0 ]; then
  cat <<EOF

EOF
  exit 0
fi

case "$1" in
  start)
    start-stop-daemon --start --quiet --pidfile $DHCPDPID \
      --exec ${DAEMON} -- ${ARGS}
    ;;
  stop)
    start-stop-daemon --stop --quiet --pidfile $DHCPDPID
    ;;
  restart | force-reload)
    start-stop-daemon --stop --quiet --pidfile $DHCPDPID
    sleep 2
    start-stop-daemon --start --quiet --pidfile $DHCPDPID \
      --exec {$DAEMON} -- ${ARGS}
    ;;
  *)
    echo "Usage: /etc/init.d/dhcp {start|stop|restart|force-reload}"
    exit 1
esac

exit 0