Problemas para monitorear paquetes DHCP
Fecha: febrero del 2020
Escenario
Con la necesidad de monitorear tráfico DHCP en producción y sin los resultados
previstos, se armó una maqueta donde “experimentar sin romper”.
El desafío es monitorear el tráfico DHCP discover que en teoría nunca llegaba al
DHCP server, pasando por un switch de capa 3 que ejecuta un DHCP relay, y un
router 1841 que actúa de server.
La idea era no aplicar un debug ya que el equipo en producción tiene una carga
importante de tráfico.
En el escenario original no tenía acceso al server ni manera de monitorearlo, por
ello debía asegurarme la recepción y envío del tráfico DHCP.
Al implementar una ACL entrante aplicada a la interfaceque mira hacia la PC y
que matchee tráfico DHCP, se decubre que la sentencia “any any” no aplica a
255.255.255.255, y esta es la finalidad de este laboratorio.
Secuencia de solicitud DHCP mediante relay:
Fuente: https://github.com
1.- Configuración de un DHCP server en un router:
Cisco1841#conf
t
Enter configuration commands, one per
line. End with CNTL/Z.
Cisco1841(config)#ip dhcp pool Vlan2
Cisco1841(dhcp-config)#network 192.168.2.0
Cisco1841(dhcp-config)#default-router 192.168.2.1
Cisco1841(dhcp-config)#exit
Cisco1841(config)#
Cisco1841(config)#ip dhcp excluded-address 192.168.2.1
192.168.2.99
Cisco1841(config)#int fa0/0
Cisco1841(config-if)#ip add 192.168.1.10 255.255.255.0
Cisco1841(config-if)#no shut
Cisco1841(config-if)#end
Cisco1841#
2.- Configuración del switch layer 3 con relay DHCP:
Cisco3850#conf
t
Cisco3850(config)#interface Vlan1
Cisco3850(config-if)#ip address 192.168.1.1 255.255.255.0
Cisco3850(config-if)#exit
Cisco3850(config)#ip access-list extended LOGS
Cisco3850(config-ext-nacl)#permit udp host 0.0.0.0 host 255.255.255.255 eq bootps log
Cisco3850(config-ext-nacl)#permit udp any any eq bootps log
Cisco3850(config-acl)#permit ip any any
Cisco3850(config-acl)#exit
Cisco3850(config)#interface Vlan2
Cisco3850(config-if)#ip address 192.168.2.1 255.255.255.0
Cisco3850(config-if)#ip helper-address 192.168.1.10
Cisco3850(config-if)#ip access-group LOGS in
Cisco3850(config-if)#end
3.- Prueba de conectividad entre el DHCP server y el gateway:
Cisco1841#ping
192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos
to 192.168.1.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip
min/avg/max = 1/1/4 ms
Cisco1841#
4.- Primer prueba DHCP:
C:\>ipconfig /all
Configuración IP de Windows
Adaptador de Ethernet Conexión de área local:
Sufijo DNS específico para la conexión. . :
Descripción . . . . . . . . . . . . . . . . . . . . .: Conexión de red Intel(R) PRO/100VE
Dirección física. . . . . . . . . . . . . . . . . . : 00-1B-38-7E-F1-71
DHCP habilitado
. . . . . . . . . . . . . . . . : sí
Configuración automática habilitada . . . : sí
Dirección IPv4. . . . . . . . . . . . . . . . . . . : 192.168.2.100(Preferido)
Máscara de subred . . . . . . . . . . . . . . : 255.255.255.0
Concesión obtenida. . . . . . . . . . . . . . : miércoles, 05 de febrero de 2020 7:56:00
La concesión expira . . . . . . . . . . . . . . : jueves, 06 de febrero de 2020 7:56:00
Puerta de enlace predeterminada . .: 192.168.2.1
Servidor DHCP
. . . . . . . . . . . . . . . . . . : 192.168.1.10
NetBIOS sobre TCP/IP. . . . . . . . . . . . : habilitado
5.- Verificación en el server:
Cisco1841#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 0100.1b38.7ef1.71 Feb 04 2020 03:47 PM Automatic
Cisco1841#
6.- La ACL de monitoreo no muestra los paquetes DHCP discover (255.255.255.255):
*Feb 4 14:32:14.425: %SEC-6-IPACCESSLOGP:
list LOGS permitted udp 192.168.2.100(68) -> 192.168.1.10(67), 1 packet
*Feb 4 14:34:31.808: %SEC-6-IPACCESSLOGP:
list LOGS permitted udp 192.168.2.100(68) ->
192.168.1.10(67), 2 packets
*Feb 4 14:36:25.193: %SEC-6-IPACCESSLOGP:
list LOGS permitted udp 192.168.2.100(68) ->
192.168.1.10(67), 2 packets
(no hay logs a -> 255.255.255.255)
7.- Se probó con una ACL numerada en vez de nombrada:
Cisco3850(config)#access-lists 100 permit ip host 0.0.0.0 host
255.255.255.255 log
Cisco3850(config)#access-lists 100 permit udp any any eq bootps
log
Cisco3850(config)#access-lists 100 permit ip any any
Cisco3850(config)#interface Vlan2
Cisco3850(config-if)#no ip access-group LOGS in
Cisco3850(config-if)#ip access-group 100 in
Cisco3850(config-if)#
8.- Verificación:
*Feb 4 15:08:08.917: %SEC-6-IPACCESSLOGP:
list 100 permitted udp 192.168.2.102(68) ->
192.168.1.10(67), 1 packet
Cisco3850#sh
access-list 100
Extended IP access list 100
10 permit
ip host 0.0.0.0 host 255.255.255.255 log (no matchea)
20
permit udp any any eq bootps log (1 match)
30
permit ip any any (4
matches)
Cisco3850#
*Feb 4 14:32:14.425: %SEC-6-IPACCESSLOGP:
list LOGS permitted udp 192.168.2.100(68) -> 192.168.1.10(67), 1 packet
*Feb 4 14:32:14.425: %SEC-6-IPACCESSLOGP:
list LOGS permitted udp 192.168.2.100(68) ->
192.168.1.10(67), 1 packet
*Feb 4 14:32:14.425: %SEC-6-IPACCESSLOGP:
list LOGS permitted udp 192.168.2.100(68) ->
192.168.1.10(67), 1 packet
9.- Pruebas con debug:
9.1.- Se desafecta la ACL de la interface:
Cisco3850#conf
t
Enter configuration commands, one per
line. End with CNTL/Z.
Cisco3850(config)#int vlan 2
Cisco3850(config-if)#no ip access-group 100 in
Cisco3850(config-if)#end
Cisco3850#
9.2.-
Se implementa debug:
Cisco3850#debug
ip packet ?
<1-199> Access list
<1300-2699>
Access list (expanded range)
detail Print
more debugging detail
<cr> <cr>
Cisco3850#debug
ip packet 100
IP packet debugging is on for access list 100
Cisco3850#
9.3.- Se realiza un /release y /renew:
*Feb 4 16:05:27.993: %SEC-6-IPACCESSLOGP:
list 100 permitted udp 0.0.0.0(68) -> 255.255.255.255(67),
1 packet
(este es el DHCP DISCOVER entre la PC y el gateway)
*Feb 4 16:05:27.993: IP: s=0.0.0.0 (Vlan2), d=255.255.255.255, len 328, input feature, Access List(47),
*Feb 4 16:05:27.993: IP: s=0.0.0.0 (Vlan2),
d=255.255.255.255, len 328, input feature, MCI
Check(109),
---algunos flags del
debug se omitieron para simplificar lectura---
*Feb 4 16:05:27.994: IP: s=0.0.0.0 (Vlan2),
d=255.255.255.255, len 328, rcvd 2
*Feb 4 16:05:27.994: IP: s=0.0.0.0 (Vlan2),
d=255.255.255.255, len 328, stop process pak for forus packet
*Feb 4 16:05:27.994: IP: tableid=0, s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), routed via FIB
(este es el DHCP DISCOVER entre el relay y el server)
*Feb 4 16:05:27.994: IP: s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), len 328, sending
*Feb 4 16:05:27.995: IP: s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), len 328, sending
full packet
*Feb 4 16:05:29.996: %SEC-6-IPACCESSLOGP:
list 100 permitted udp 192.168.1.10(67) -> 192.168.2.1(67), 1 packet
(esto es por el permit udp any
any eq 67 de la ACL 100 que
está asociada al proceso debug)
*Feb 4 16:05:29.996: IP: tableid=0,
s=192.168.1.10 (Vlan1), d=192.168.2.1 (Vlan2), routed via RIB
(este es el DHCP OFFER entre el server y el relay)
*Feb 4 16:05:29.996: IP: s=192.168.2.1 (local), d=255.255.255.255
(Vlan2), len 328, sending broad/multicast
(este es el DHCP OFFERentre
el relay y la PC)
*Feb 4 16:05:29.999: IP: s=0.0.0.0 (Vlan2), d=255.255.255.255, len 338, input feature, Access List(47),
(este es el DHCP REQUEST desde la PC al relay)
*Feb 4 16:05:29.999: IP: s=0.0.0.0 (Vlan2),
d=255.255.255.255, len 338, input feature, MCI Check(109),
*Feb 4 16:05:29.999: IP: s=0.0.0.0 (Vlan2),
d=255.255.255.255, len 338, rcvd 2
*Feb 4 16:05:30.000: IP: s=0.0.0.0 (Vlan2),
d=255.255.255.255, len 338, stop process pak for forus packet
*Feb 4 16:05:30.000: IP: tableid=0, s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), routed via FIB
(este es el DHCP REQUEST entre el relay y el server)
*Feb 4 16:05:30.000: IP: s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), len 338, sending
*Feb 4 16:05:30.001: IP: s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), len 338, sending
full packet
*Feb 4 16:05:30.003: IP: tableid=0, s=192.168.1.10 (Vlan1), d=192.168.2.1 (Vlan2),
routed via RIB
*Feb 4 16:05:30.003: IP: s=192.168.2.1 (local), d=255.255.255.255
(Vlan2), len 328, sending broad/multicast
(este es el DHCP ACK entre el relay y la PC)
*Feb 4 16:05:33.315: %SEC-6-IPACCESSLOGP:
list 100 permitted udp 192.168.2.100(68) ->
255.255.255.255(67), 1 packet
*Feb 4 16:05:33.315: IP: s=192.168.2.100 (Vlan2), d=255.255.255.255,
len 328, input feature, Access List(47),
(este es el DHCP INFORM desde la PC al gateway )
*Feb 4 16:05:33.316: IP: s=192.168.2.100
(Vlan2), d=255.255.255.255, len 328, input feature,
MCI Check(109),
*Feb 4 16:05:33.316: IP: s=192.168.2.100
(Vlan2), d=255.255.255.255, len 328, rcvd 2
*Feb 4 16:05:33.316: IP: s=192.168.2.100
(Vlan2), d=255.255.255.255, len 328, stop process pak for forus packet
*Feb 4 16:05:33.317: IP: tableid=0, s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), routed via FIB
(este es el DHCP INFORM desde el relay al server)
*Feb 4 16:05:33.317: IP: s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), len 328, sending
*Feb 4 16:05:33.317: IP: s=192.168.2.1
(local), d=192.168.1.10 (Vlan1), len 328, sending
full packet
*Feb 4 16:05:33.319: IP: tableid=0,
s=192.168.1.10 (Vlan1), d=192.168.2.1 (Vlan2), routed via RIB
(este es el DHCP ACK desde el server al relay)
*Feb 4 16:05:33.320: IP: s=192.168.2.1 (local), d=255.255.255.255
(Vlan2), len 328, sending broad/multicast
(este es el DHCP ACK desde el relay a la PC)
Cisco3850#
9.4.- Verificación de los matchs de ACL:
Cisco3850#sh
access-list 100
Extended IP access list 100
10
permit ip host 0.0.0.0 host 255.255.255.255 log (8 matches)(ahora si hubo match)
20
permit udp any any eq bootps log (24 matches)
30
permit udp any eq bootps any log (4 matches)
Cisco3850#
10.- Pruebas con release DHCP:
10.1.- Se genera la ACL 101 para el tráfico 3850 –> DHCP server:
Cisco3850(config)#access-list 101 permit ip host 192.168.2.1
host 192.168.1.10
Cisco3850(config)#exit
Cisco3850#
10.2.- Se asocial al debug:
Cisco3850#debug
ip packet 101
IP packet debugging is on for access list 101
Cisco3850#
10.3.- Se ejecuta el reléase:
C:\>ipconfig /release
Configuración IP de Windows
Adaptador de Ethernet Conexión de área local:
Sufijo DNS específico para la conexión. . :
Puerta de enlace predeterminada . . . . . :
C:\>
Se verifica que no hay tráfico IP entre 2.1 y 1.10 ya que el release es entre
2.100 y 1.10:
Detalle: existe tráfico en layer 2 de una trama con MAC origen Cisco 3850 y destino DHCP server.
11.- DHCP visto desde el server:
11.1.- Se genera un debug del DHCP:
Cisco1841#debug ip dhcp server
events
Cisco1841#
11.2.-
Proceso DHCP Relay:
*Feb 5 12:13:40.031: DHCPD: Sending
notification of TERMINATION:
*Feb 5 12:13:40.031: DHCPD: address 192.168.2.100 mask
255.255.255.0
*Feb 5 12:13:40.031: DHCPD: reason flags: RELEASE
*Feb 5 12:13:40.031: DHCPD: htype 1 chaddr 001b.387e.f171
*Feb 5 12:13:40.031: DHCPD: lease time remaining (secs) = 86056
*Feb 5 12:13:40.031: DHCPD: returned 192.168.2.100 to address pool
Vlan2.
11.3.-
DHCP discover/request:
*Feb 5 12:14:30.851: DHCPD: checking for
expired leases.
*Feb 5 12:15:09.343: DHCPD: Sending
notification of DISCOVER:
*Feb 5 12:15:09.343: DHCPD: htype 1 chaddr 001b.387e.f171
*Feb 5 12:15:09.343: DHCPD: remote id
020a0000c0a8010a00000000
*Feb 5 12:15:09.343: DHCPD: circuit id
00000000
*Feb 5 12:15:09.343: DHCPD: Seeing if there
is an internally specified pool class:
*Feb 5 12:15:09.343: DHCPD: htype 1 chaddr 001b.387e.f171
*Feb 5 12:15:09.343: DHCPD: remote id
020a0000c0a8010a00000000
*Feb 5 12:15:09.343: DHCPD: circuit id
00000000
*Feb 5 12:15:11.343: DHCPD: client requests 192.168.2.100.
*Feb 5 12:15:11.343: DHCPD: Adding binding
to radix tree (192.168.2.100)
*Feb 5 12:15:11.343: DHCPD: Adding binding
to hash tree
*Feb 5 12:15:11.343: DHCPD: assigned IP address 192.168.2.100 to client
0100.1b38.7ef1.71.
*Feb 5 12:15:11.347: DHCPD: Sending
notification of ASSIGNMENT:
*Feb 5 12:15:11.347: DHCPD: address
192.168.2.100 mask 255.255.255.0
*Feb 5 12:15:11.347: DHCPD: htype 1 chaddr 001b.387e.f171
*Feb 5 12:15:11.347: DHCPD: lease time
remaining (secs) = 86400
11.4.- Verificación:
Cisco1841#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 0100.1b38.7ef1.71 Feb 05 2020 12:15 PM Automatic
Cisco1841#
12.- Configuración de los equipos:
Cisco1841#sh runn (solo lo mas relevante)
Building configuration...
Current configuration :
1114 bytes
!
hostname Cisco1841
!
ip dhcp
excluded-address 192.168.2.1 192.168.2.99
!
ip dhcp pool
Vlan2
network 192.168.2.0 255.255.255.0
default-router 192.168.2.1
!
interface FastEthernet0/0
ip address 192.168.1.10
255.255.255.0
!
interface FastEthernet0/1
ip address 192.168.2.2
255.255.255.0
!
ip route 192.168.2.0 255.255.255.0
192.168.1.1
!
end
Cisco1841#
Cisco3850#sh runn (solo lo mas relevante)
Building configuration...
Current configuration :
8717 bytes
!
version 16.9
no service pad
service timestamps debug datetime msec
service timestamps log datetime
msec
!
hostname Cisco3850
!
interface GigabitEthernet1/0/1
switchport mode access
spanning-tree portfast
!
interface GigabitEthernet1/0/2
switchport access vlan 2
switchport mode access
spanning-tree portfast
!
interface GigabitEthernet1/0/3
!
interface GigabitEthernet1/0/4
!
---resto de las interfaces iguales---
!
interface TenGigabitEthernet1/1/4
!
interface Vlan1
ip address 192.168.1.1
255.255.255.0
!
interface Vlan2
ip address 192.168.2.1
255.255.255.0
ip helper-address 192.168.1.10
!
ip access-list extended LOGS
permit udp host 0.0.0.0 host
255.255.255.255 eq bootps
log
permit udp any any
eq bootps log
permit ip any any
!
access-list 100 permit ip
host 0.0.0.0 host 255.255.255.255 log
access-list 100 permit udp
any any eq bootps log
access-list 100 permit udp
any eq bootps any log
!
access-list 101 permit ip
host 192.168.2.1 host 192.168.1.10
!
!
end
Cisco3850#
(2020) Catch me if you can
Rosario, Argentina