Análisis del rewrite de layer 2 de CEF

Fecha: 24 de agosto del 2023

 

Escenario

 

Este laboratorio analiza el proceso de reescritura (rewrite) de layer 2 por parte de CEF al enviar un paquete,

y encapsularlo en una nueva trama en el segmento correspondiente al next-hop de una ruta destino.

En el escenario anterior se realizaron pruebas de toma de decisiones en base a rutas destino, y en una de

las sesiones de captura de tráfico, obtuvimos una muestra de la ausencia (parcial) de reescritura (rewrite)

por parte de CEF, generado una trama con una MAC de origen que no pertenece al propio router.

 

En resumen, capturamos una trama generada por el Router-C, pero con una MAC de origen del Router-A.

 

 

 

Acerca del rewrite CEF:

 

El proceso de reecritura (rewite) de CEF no es nada diferente a lo que ya conocemos del CCNA, una trama arriba

al routrer, se compara la dirección MAC destino contra la propia dirección MAC, si es coincidente se procesa el

payload (digamos un paquete IP) se toma la decisión de reenvío, se le descuenta 1 TTL, se le calcula el checksum

de layer 3 y se genera una nueva trama con dirección MAC destino del próximo salto decidido anteriormente y la

propia dirección MAC como origen. Además se le calcula un nuevo CRC ya que la trama/paquete cambió en varios

valores de las diferentes cabeceras.

En el caso de CEF, el router dispone de una tabla de adyacencias donde las MAC destino y origen más el campo

type se encuentra predefinido y no es necesario consultar la tabla de ARP. Esta última sólo actualiza la tabla de

adyacencias en caso de algún cambio de layer 2.

 

1.- Captura del paquete en la PC de origen:

 

 

Frame 1: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface eth0, id 0

Ethernet II, Src: 00:1b:38:fe:8a:c7, Dst: cc:46:d6:2b:5a:54 (Router-A)

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0x1dc2 (7618)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 64

    Protocol: TCP (6)

    Header Checksum: 0x9a85 [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 56218, Dst Port: 23, Seq: 0, Len: 0

 

 

2.- Captura de la trama/paquete en la PC destino (sin rewrite):

 

Aquí tenemos la captura de las tramas/paquetes con ausencia de rewrite, donde la MAC origen es cc:46:d6:2b:5a:54

y debería ser 70:81:05:b5:77:82, también confirmamos que es un segundo salto entre la PC origen y destino ya que

el TTL es de 62 (64 en el primer segmento, 63 entre Router-A y Router-C y 62 entre Router-C y la PC destino).

Un detalle es que sí se reescribe la MAC de destino, que originalmente era cc:46:d6:2b:5a:54 (Router-A que es  el

gateway de la PC origen), y ahora es 00:1b:38:7e:f1:71 (la PC de destino).

 

 

Detalle: vemos tres tramas del intento para verificar que no fué algo de sólo la primera trama u otra cosa que sucede

en los primeros paquetes o tramas tipo cuando se pierde el primer ping. Aquí en todo caso lo raro es con la MAC origen

y no la de destino que no se pudo resolver por algún motivo.

 

Frame 1: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface  id 0

Ethernet II, Src: cc:46:d6:2b:5a:54, Dst: 00:1b:38:7e:f1:71

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0xd785 (55173)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 62

    Protocol: TCP (6)

    Header Checksum: 0xe2c1 [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 34568, Dst Port: 23, Seq: 0, Len: 0

 

Frame 2: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface  id 0

Ethernet II, Src: cc:46:d6:2b:5a:54, Dst: 00:1b:38:7e:f1:71

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0xe609 (58889)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 62

    Protocol: TCP (6)

    Header Checksum: 0xd43d [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 34570, Dst Port: 23, Seq: 0, Len: 0

 

Frame 3: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface  id 0

Ethernet II, Src: cc:46:d6:2b:5a:54, Dst: 00:1b:38:7e:f1:71

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0x1412 (5138)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 62

    Protocol: TCP (6)

    Header Checksum: 0xa635 [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 34572, Dst Port: 23, Seq: 0, Len: 0

 

 

3.- Captura de la trama/paquete en la PC destino (con rewrite):

 

 

Frame 1: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface  id 0

Ethernet II, Src: 70:81:05:b5:77:82, Dst: 00:1b:38:7e:f1:71

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0x718b (29067)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 62

    Protocol: TCP (6)

    Header Checksum: 0x48bc [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 35148, Dst Port: 23, Seq: 0, Len: 0

 

Frame 2: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface  id 0

Ethernet II, Src: 70:81:05:b5:77:82, Dst: 00:1b:38:7e:f1:71

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0xea52 (59986)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 62

    Protocol: TCP (6)

    Header Checksum: 0xcff4 [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 35150, Dst Port: 23, Seq: 0, Len: 0

 

Frame 3: 74 bytes on wire (592 bits), 74 bytes captured (592 bits) on interface  id 0

Ethernet II, Src: 70:81:05:b5:77:82, Dst: 00:1b:38:7e:f1:71

Internet Protocol Version 4, Src: 192.168.0.10, Dst: 192.168.1.10

    0100 .... = Version: 4

    .... 0101 = Header Length: 20 bytes (5)

    Differentiated Services Field: 0x10 (DSCP: Unknown, ECN: Not-ECT)

    Total Length: 60

    Identification: 0x85eb (34283)

    010. .... = Flags: 0x2, Don't fragment

    ...0 0000 0000 0000 = Fragment Offset: 0

    Time to Live: 62

    Protocol: TCP (6)

    Header Checksum: 0x345c [validation disabled]

    [Header checksum status: Unverified]

    Source Address: 192.168.0.10

    Destination Address: 192.168.1.10

Transmission Control Protocol, Src Port: 35152, Dst Port: 23, Seq: 0, Len: 0

 

 

4.- Verificación de la MAC del Router-A:

 

4.1.- En la tabla ARP:

 

Router-A#sh arp

Protocol  Address          Age (min)  Hardware Addr   Type   Interface

Internet  10.0.0.1                -            cc46.d62b.5a54  ARPA   Vlan100 

Internet  10.0.0.2               18          0017.95c0.aca2  ARPA   Vlan100 

Internet  10.0.0.5                -            cc46.d62b.5a54 ARPA   Vlan104 (link Router-A –> Router-C)

Internet  10.0.0.6               17          7081.05b5.7782  ARPA   Vlan104 (Router-C)

Internet  192.168.0.1           -           cc46.d62b.5a54  ARPA   Vlan1    (red LAN)

Internet  192.168.0.10         4          001b.38fe.8ac7  ARPA    Vlan1

Internet  192.168.0.11         1          001b.38fe.8ac7  ARPA    Vlan1

Router-A#

 

4.2.- En la interface de salida:

 

Router-A#sh interfaces vlan 104 (esta es la interface que reenvía con su MAC de origen a Router-C)

Vlan100 is up, line protocol is up

  Hardware is EtherSVI, address is cc46.d62b.5a54 (bia cc46.d62b.5a54)

  Internet address is 10.0.0.5/30

  MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive not supported

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input 00:00:05, output never, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue: 0/40 (size/max)

  5 minute input rate 0 bits/sec, 0 packets/sec

  5 minute output rate 0 bits/sec, 0 packets/sec

     91 packets input, 8160 bytes, 0 no buffer

     Received 1 broadcasts (0 IP multicasts)

     0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

     91 packets output, 8160 bytes, 0 underruns

     0 output errors, 1 interface resets

     0 unknown protocol drops

     0 output buffer failures, 0 output buffers swapped out

Router-A#

 

4.3.- En la tabla de adyacencias:

 

Router-A#sh adjacency detail (la tabla de adyacencias L2/L3)

Protocol Interface       Address

IP       Vlan1               192.168.0.10(7) (la PC de origen)

                                   3 packets, 162 bytes

                                   epoch 0

                                   sourced in sev-epoch 2

                                   Encap length 14

                                   001B38FE8AC7CC46D62B5A540800

                                   ARP

IP       Vlan100           10.0.0.2(10) (el link a Router-B)

                                   5 packets, 370 bytes

                                   epoch 0

                                   sourced in sev-epoch 1

                                   Encap length 14

                                   001795C0ACA2CC46D62B5A540800

                                   ARP

IP       Vlan104           10.0.0.6(10) (el link a Router-C)

                                   3 packets, 222 bytes

                                   epoch 0

                                   sourced in sev-epoch 2

                                   Encap length 14

                                   708105B57782CC46D62B5A540800

                                   |                         |                         |

                                   MAC destino    MAC origen     campo type del payload

                                   ARP

Router-A#

 

 

5.- Verificación de la MAC del Router-C:

 

5.1.- En la tabla ARP:

 

Router-C#sh arp

Protocol  Address          Age (min)  Hardware Addr   Type   Interface

Internet  10.0.0.5              4   cc46.d62b.5a54   ARPA   Vlan104

Internet  10.0.0.6              -    7081.05b5.7782   ARPA   Vlan104

Internet  192.168.1.1        -    0000.0c07.ac01   ARPA    Vlan1

Internet  192.168.1.3        -    7081.05b5.7782  ARPA    Vlan1

Internet  192.168.1.10      0   001b.387e.f171   ARPA    Vlan1

Router-C#

 

5.2.- En la interface de salida:

 

Router-C#sh int vlan 1

Vlan1 is up, line protocol is up

  Hardware is EtherSVI, address is 7081.05b5.7782 (bia 7081.05b5.7782) (la dirección de origen con la que debe escribir la trama)

  Internet address is 192.168.1.3/24

  MTU 1500 bytes, BW 100000 Kbit/sec, DLY 100 usec,

     reliability 255/255, txload 1/255, rxload 1/255

  Encapsulation ARPA, loopback not set

  Keepalive not supported

  ARP type: ARPA, ARP Timeout 04:00:00

  Last input 00:00:06, output never, output hang never

  Last clearing of "show interface" counters never

  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0

  Queueing strategy: fifo

  Output queue: 0/40 (size/max)

  5 minute input rate 0 bits/sec, 0 packets/sec

  5 minute output rate 0 bits/sec, 0 packets/sec

     179 packets input, 15244 bytes, 0 no buffer

     Received 50 broadcasts, 0 runts, 0 giants, 0 throttles

     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored

     131 packets output, 12108 bytes, 0 underruns

     0 output errors, 1 interface resets

     0 unknown protocol drops

     0 output buffer failures, 0 output buffers swapped out

Router-C#

 

5.3.- En la tabla de adyacencias:

 

Router-C#sh adjacency detail

Protocol Interface       Address

IP       Vlan1               192.168.1.10(7)

                                   10 packets, 1140 bytes

                                   epoch 0

                                   sourced in sev-epoch 0

                                   Encap length 14

                                   001B387EF171708105B577820800

                                   |                         |                       |

                                   MAC destino    MAC origen   campo type del payload

                                   ARP

IP       Vlan104                   10.0.0.5(11)

                                   10 packets, 1140 bytes

                                   epoch 0

                                   sourced in sev-epoch 0

                                   Encap length 14

                                   CC46D62B5A54708105B577820800

                                   ARP

Router-C#

 

 

6.- Resumiendo:

 

Esta captura se considera un “caso raro” y no pudo reproducirse nuevamente.

Se descarta cualquier mala conexión de los equipos ya que fue dentro de la segunda sesión de capturas para

el laboratorio anterior, de hecho, las pruebas con ping de los puntos 4.2 y 4.3 salieron con la MAC correcta.

Lamentablemente tampoco se generaron logs de ningún tipo en el Router-C.

 

…misterios del networking…

 

  

(2023) Identity crisis

Rosario, Argentina