Importante: Esto sólo capturará paquetes CDP (Cisco Discovery Packets)
tcpdump -nn -v -i eth3 -s 1500 -c 1 'ether[20:2] == 0x2000'
Donde,
-i es la interfaz que queremos testear (ethX)
-nn nos hará una resolución inversa del nombre del switch y nos devolverá la IP. Es opcional. Si no lo ponemos nos dará el el FQDN. Se ve en la linea Address (0x02)
-v Indica modo verbose. Tenemos -vv y -vvv A más nivel de detalle, más uves.
-s Viene a decir el tamaño del paquete. Lo hacemos coincidir con la MTU por defecto. Podemos ponerle un valor más bajo, pero nos puede truncar el paquete y no darnos toda la información.
-c Nos da el número de paquetes que queremos capturar. Para este caso, con uno nos basta. Si no lo indicamos, el comando seguirá capturando hasta que lo cortemos.
Expression Finalmente le indicaremos la expresión por la que queremos filtrar. En nuestro caso es:ether[20:2] == 0x2000Esto chequea los bytes 20 y 21 desde el inicio de la cabecera ethernet con un valor 2000 (hex)
El resultado del comando sería algo así:
[root@redhat01]# tcpdump -nn -v -i eth5 -s 1500 -c 1 'ether[20:2] == 0x2000'
tcpdump: listening on eth5, link-type EN10MB (Ethernet), capture size 1500 bytes
09:21:49.670206 CDPv2, ttl: 180s, checksum: 692 (unverified), length 253
Device-ID (0x01), length: 23 bytes: 'SWITCH01'
Address (0x02), length: 13 bytes: IPv4 (1) 10.2.27.39
Port-ID (0x03), length: 12 bytes: 'Ethernet1/14'
Capability (0x04), length: 4 bytes: (0x00000229): Router, L2 Switch, IGMP snooping
Version String (0x05), length: 67 bytes:
Cisco Nexus Operating System (NX-OS) Software, Version 5.1(3)N2(1b)
Platform (0x06), length: 11 bytes: 'N5K-C5548UP'
Native VLAN ID (0x0a), length: 2 bytes: 3
AVVID trust bitmap (0x12), length: 1 byte: 0x00
AVVID untrusted ports CoS (0x13), length: 1 byte: 0x00
Duplex (0x0b), length: 1 byte: full
MTU (0x11), length: 4 bytes: 1500 bytes
System Name (0x14), length: 10 bytes: 'SWITCH01'
System Object ID (not decoded) (0x15), length: 14 bytes:
0x0000: 060c 2b06 0104 0109 0c03 0103 883c
Management Addresses (0x16), length: 13 bytes: IPv4 (1) 10.2.9.34
Physical Location (0x17), length: 13 bytes: 0x00/snmplocation
1 packets captured
2 packets received by filter
0 packets dropped by kernel
El comando lanzado con un valor de -s muy bajo
[root@redhat01]# tcpdump -nn -v -i eth5 -s 68 -c 1 'ether[20:2] == 0x2000'
tcpdump: listening on eth5, link-type EN10MB (Ethernet), capture size 68 bytes
09:50:49.927614 CDPv2, ttl: 180s, checksum: 692 (unverified), length 253
Device-ID (0x01), length: 23 bytes: 'SWITCH01'[|cdp]
1 packets captured
1 packets received by filter
0 packets dropped by kernel
Interpretando la salida del comando
Device-ID (0x01), length: 23 bytes: 'SWITCH01'
^ Nombre del switch
Address (0x02), length: 13 bytes: IPv4 (1) 10.2.27.39
^ IP o nombre del switch (según si hemos usado nn o no)
Version String (0x05), length: 67 bytes:
Cisco Nexus Operating System (NX-OS) Software, Version 5.1(3)N2(1b)
Cisco Nexus Operating System (NX-OS) Software, Version 5.1(3)N2(1b)
^ Versión del IO del Cisco
Platform (0x06), length: 11 bytes: 'N5K-C5548UP'
^ Tipo de dispositivo
Port-ID (0x03), length: 12 bytes: 'Ethernet1/14'
^ Puerto del switch
También, podéis no complicaros la vida como yo, e instalar el paquete cdpr (si lo tenéis en vuestros repositorios)
No hay comentarios:
Publicar un comentario