DHCP



Comenzamos con la instalacion




apt-get install dhcp

luego vamos a editar el dhcp.conf

nano /etc/dhcp.conf
y lo editamos de esta forma


#---------inicio del fichero------#

# Sample /etc/dhcpd.conf
# (add your comments here)

# option definitions common to all supported networks...


default-lease-time 600;
max-lease-time 7200;
option subnet-mask (mascara de la subred);
option broadcast-address (la direccion de la broadcast) ;
option routers (aqui pones la ip de la tarjeta de red interna);
option domain-name-servers (aqui los ip del server, de la eth0 y la eth1);
option domain-name "tu dominio";
option netbios-name-servers (ip de la tarjeta interna);

subnet (subnet) netmask (mascara) {
range (rango de ip que queremos que abarque el dhcp);
}

#------fin del fichero------#


luego reiniciamos el dhcp y ya

invoke-rc.d dhcp restart

ejemplo

mi ip del server es: 192.168.4.60
mi virtual: 192.168.0.1

quedaria asi el fichero

#-----inicio del fichero-----#

# Sample /etc/dhcpd.conf
# (add your comments here)

# option definitions common to all supported networks...


default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.4.61;
option routers 192.168.0.1;
option domain-name-servers 192.168.0.1, 192.168.4.60;
option domain-name "lpjc";
option netbios-name-servers 192.168.0.1;

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.2 192.168.0.100;
}

#-----------fin del fichero------#


luego

si reinicias despues de configurar dhcpd.conf
te va a dar este error

No subnet declaration for eth0 (ip del server).
Please write a subnet declaration in your dhcpd.conf file for the
network segment to which interface eth0 is attached.
exiting.

que tenemos que hacer
es sencillo

vamos a /etc/default/ y editamos el fichero dhcp

aparecera esto

#---------------------inicio del fichero-------#

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES=""

#-----fin del fichero---#

que tenemos que hacer, solo en lo ultimo declarar donde dice INTERFACES la eth que quieres que salga el dhcp, en este caso la eth01
quedaria

#---inicio del fichero----#

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth1"

#----------------fin del fichero-----------#

guardas los cambios
reinicias dhcp y ya: invoke-rc.d dhcp restart

y todo funciona perfectamente