Pruebas de pool y relay DHCP en la misma
interface
Fecha: 15 de agosto del 2019
Escenario
Este escenario es muy simple, plantea y analiza la situación de un router que ofrece
DHCP y además tiene un relay hacia un server en caso de que el pool se agote.
Por cuestiones de simplicidad, en el router creamos un pool de una única IP para poder
agotarlo y verificar el reevío de las peticiones mediante el relay.
Ambos pools tienen rangos de IP separados, ya que si un pool estuviese agotado obviamente
las direcciones estarían ocupadas y tampoco podrian ser ofrecidas por el server.
De todas maneras DHCP mitiga o detecta IP duplicadas mediante ping o ARP.
1.- Verificación inicial:
1.1.- En el cliente DHCP:
Como cliente DHCP utilizamos un router Mikrotik para poder cambiarle la MAC
address y realizar una petición de una IP diferente simulando otro equipo, y con
el pool de una única dirección agotado, el router debería ejecutar el relay.
[admin@MikroTik] > int ethernet print
Flags: X - disabled, R - running, S - slave
# NAME
MTU MAC-ADDRESS ARP MASTER-PORT SWITCH
0 R ether1 1500 E4:8D:8C:AF:DE:6F
enabled none switch1
---omitido---
[admin@MikroTik] >
1.2.- En el router:
1.2.1.- Resultado de la transacción DHCP PC -> router:
Router#debug
ip dhcp server packet
DHCP server packet debugging is on.
Router#debug
ip dhcp server events
DHCP server event debugging is on.
Router#
*Aug 15 09:21:31.435:
DHCPD: DHCPDISCOVER received from client 01e4.8d8c.afde.6f on interface Vlan2.
*Aug 15 09:21:31.435: DHCPD: Seeing if there is
an internally specified pool class:
*Aug 15 09:21:31.435: DHCPD: htype 1 chaddr e48d.8caf.de6f
*Aug 15 09:21:31.435: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:21:31.435: DHCPD: circuit id 00000000
*Aug 15 09:21:31.435: DHCPD: Allocate an
address without class information (192.168.2.0)
*Aug 15 09:21:31.435: DHCPD: Allocated binding
879DF9B4
*Aug 15 09:21:31.435:
DHCPD: Adding binding to radix tree (192.168.2.100)
*Aug 15 09:21:31.435: DHCPD: Adding binding to
hash tree
*Aug 15 09:21:31.435:
DHCPD: assigned IP address 192.168.2.100 to client 01e4.8d8c.afde.6f.
*Aug 15 09:21:31.435: DHCPD: Saving workspace
(ID=0x41000001)
*Aug 15 09:21:33.435: DHCPD: Reprocessing saved
workspace (ID=0x41000001)
*Aug 15 09:21:33.435: DHCPD: Sending
notification of DISCOVER:
*Aug 15 09:21:33.435: DHCPD: htype 1 chaddr e48d.8caf.de6f
*Aug 15 09:21:33.435: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:21:33.435: DHCPD: circuit id 00000000
*Aug 15 09:21:33.435: DHCPD: DHCPDISCOVER
received from client 01e4.8d8c.afde.6f on interface Vlan2.
*Aug 15 09:21:33.435: DHCPD: Seeing if there is
an internally specified pool class:
*Aug 15 09:21:33.435: DHCPD: htype 1 chaddr e48d.8caf.de6f
*Aug 15 09:21:33.435: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:21:33.435: DHCPD: circuit id 00000000
*Aug 15 09:21:33.435:
DHCPD: Sending DHCPOFFER to client 01e4.8d8c.afde.6f (192.168.2.100).
*Aug 15 09:21:33.435: DHCPD: no option 125
*Aug 15 09:21:33.435: DHCPD: creating ARP entry
(192.168.2.100, e48d.8caf.de6f, vrf default).
*Aug 15 09:21:33.435: DHCPD: unicasting
BOOTREPLY to client e48d.8caf.de6f (192.168.2.100).
*Aug 15 09:21:33.435: DHCPD: New packet
workspace 0x8857CF7C (ID=0x6000002)
*Aug 15 09:21:33.435:
DHCPD: DHCPREQUEST received from client 01e4.8d8c.afde.6f.
*Aug 15 09:21:33.435: DHCPD: Sending
notification of ASSIGNMENT:
*Aug 15 09:21:33.435: DHCPD: address 192.168.2.100 mask 255.255.255.0
*Aug 15 09:21:33.435: DHCPD: htype 1 chaddr e48d.8caf.de6f
*Aug 15 09:21:33.435: DHCPD: lease time remaining (secs) = 86400
*Aug 15 09:21:33.435: DHCPD: No default domain
to append - abort update
*Aug 15 09:21:33.435:
DHCPD: Sending DHCPACK to client 01e4.8d8c.afde.6f (192.168.2.100).
*Aug 15 09:21:33.435: DHCPD: no option 125
*Aug 15 09:21:33.435: DHCPD: ARP entry exists
(192.168.2.100, e48d.8caf.de6f).
*Aug 15 09:21:33.439: DHCPD: unicasting
BOOTREPLY to client e48d.8caf.de6f (192.168.2.100).
1.2.2.- Verificación de la asignación en el pool del router:
Router#sh
ip dhcp bind
Bindings from all pools not associated with
VRF:
IP address Client-ID/ Lease expiration Type
Hardware
address/
User name
192.168.2.100 01e4.8d8c.afde.6f Aug 16 2019 9:21 PM Automatic
Router#
Router#sh
ip dhcp pool
Pool Vlan2 :
Utilization mark (high/low) : 100 / 0
Subnet
size (first/next) : 0 / 0
Total
addresses : 254
Leased
addresses : 1
Pending
event : none
1 subnet
is currently in the pool :
Current
index IP address range Leased addresses
0.0.0.0 192.168.2.1 - 192.168.2.254 1
Router#
2.- Cambio de MAC para simular otro dispositivo:
[admin@MikroTik] > int ethernet set mac-address=E4:8D:8C:AF:DE:6A
numbers: 0
[admin@MikroTik] >
3.- Verificación:
[admin@MikroTik] > int ethernet print
Flags: X - disabled, R - running, S - slave
# NAME
MTU MAC-ADDRESS ARP MASTER-PORT SWITCH
0 R ether1
1500 E4:8D:8C:AF:DE:6A
enabled none switch1
---omitido---
[admin@MikroTik] >
4.- Pedido de IP con la nueva MAC:
Nco esto simulamos tener un nuevo dispositivo que solicita una IP y al estar el
pool agotado fuerza el relay DHCP hacia el server.
5.- Verificación del DHCP server al que apunta el relay:
6.- Captura del tráfico de la transacción:
7.- Verificación en el router:
En negrita se encuentran los paquetes mas relevantes a la transacción.
*Aug 15 09:24:24.855:
DHCPD: DHCPDISCOVER received from client 01e4.8d8c.afde.6a on interface Vlan2.
*Aug 15 09:24:24.855: DHCPD: Seeing if there is
an internally specified pool class:
*Aug 15 09:24:24.855: DHCPD: htype 1 chaddr e48d.8caf.de6a
*Aug 15 09:24:24.855: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:24:24.855: DHCPD: circuit id 00000000
*Aug 15 09:24:24.855:
DHCPD: Allocate an address without class information (192.168.2.0)
*Aug 15 09:24:24.855:
DHCPD: subnet [192.168.2.1,192.168.2.254] in address pool Vlan2 is empty.
*Aug 15 09:24:24.855:
DHCPD: Sending notification of ASSIGNMENT FAILURE:
*Aug 15 09:24:24.855: DHCPD: htype 1 chaddr e48d.8caf.de6a
*Aug 15 09:24:24.855: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:24:24.855: DHCPD: circuit id 00000000
*Aug 15 09:24:24.855:
DHCPD: Sending notification of ASSIGNMENT_FAILURE:
*Aug 15
09:24:24.855: DHCPD: due to: POOL
EXHAUSTED
*Aug 15 09:24:24.855: DHCPD: htype 1 chaddr e48d.8caf.de6a
*Aug 15 09:24:24.855: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:24:24.855: DHCPD: circuit id 00000000
*Aug 15 09:24:24.855:
DHCPD: setting giaddr to 192.168.2.1.
*Aug 15 09:24:24.855:
DHCPD: BOOTREQUEST from 01e4.8d8c.afde.6a forwarded to 192.168.1.10. (ejecuta el relay)
*Aug 15 09:24:26.219:
DHCPD: forwarding BOOTREPLY to client e48d.8caf.de6a.
*Aug 15 09:24:26.219: DHCPD: Forwarding reply
on numbered intf
*Aug 15 09:24:26.219:
DHCPD: broadcasting BOOTREPLY to client e48d.8caf.de6a.
*Aug 15 09:24:26.219:
DHCPD: DHCPREQUEST received from client 01e4.8d8c.afde.6a.
*Aug 15 09:24:26.219:
DHCPD: excluded address: 192.168.2.200
*Aug 15 09:24:26.219:
DHCPD: Finding a relay for client 01e4.8d8c.afde.6a on interface Vlan2.
*Aug 15 09:24:26.219: DHCPD: Seeing if there is
an internally specified pool class:
*Aug 15 09:24:26.219: DHCPD: htype 1 chaddr e48d.8caf.de6a
*Aug 15 09:24:26.219: DHCPD: remote id 020a0000c0a8020201000002
*Aug 15 09:24:26.219: DHCPD: circuit id 00000000
8.- Configuración afectada:
Router#sh runn (sólo lo relevante)
Building configuration...
Current configuration : 1414 bytes
!
hostname Router
!
ip dhcp excluded-address 192.168.2.1
192.168.2.99 (fuerza a ofrecer únicamente la IP 100)
ip dhcp excluded-address 192.168.2.101
192.168.2.254
!
ip dhcp pool Vlan2
network
192.168.2.0 255.255.255.0
default-router 192.168.2.1
!
interface FastEthernet0
description Server DHCP
spanning-tree portfast
!
interface FastEthernet1
description Cliente DHCP
switchport access vlan 2
spanning-tree portfast
!
interface Vlan1
ip
address 192.168.1.1 255.255.255.0
!
interface Vlan2
ip
address 192.168.2.2 255.255.255.0
ip
helper-address 192.168.1.10 (relay DHCP)
!
end
Router#
(2019) I
want my IP, where is !
Rosario, Argentina