SoFunction
Updated on 2025-04-09

MPLS classic problem solves and avoids bgp routing black hole problem

R1---(R2---R3---R4)--R5
|__EBGP__|_____IBGP______|__EBGP_|
 12.0/24          23.0/24      34.0/24   45.0/24

R2-R4 is the MPLS domain
Redistribute directly to interfaces to EBGP neighbors on R2 and R4
Use loopback1 on R1 and R5 as internet route

r1#sh ip b
BGP table version is 7, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 11.11.11.11/32   0.0.0.0                  0         32768 i
*> 55.55.55.55/32   192.168.12.2                           0 1 3 i
*> 192.168.12.0     192.168.12.2             0             0 1 ?
*> 192.168.45.0     192.168.12.2                           0 1 ?


r5#sh ip b
BGP table version is 7, local router ID is 5.5.5.5
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 11.11.11.11/32   192.168.45.4                           0 1 2 i
*> 55.55.55.55/32   0.0.0.0                  0         32768 i
*> 192.168.12.0     192.168.45.4                           0 1 ?
*> 192.168.45.0     192.168.45.4             0             0 1 ?
-------------------------------
r2#  sh ip b
BGP table version is 5, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 11.11.11.11/32   192.168.12.1             0             0 2 i
*>i55.55.55.55/32   192.168.45.5             0    100      0 3 i
*> 192.168.12.0     0.0.0.0                  0         32768 ?
*>i192.168.45.0    4.4.4.4                  0    100      0 ?

r2#sh ip route
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/129] via 192.168.23.3, 01:26:32, Serial2/0

r2 searched the routing table and found that i55.55.55.55/32 is a bgp route, and mpls will not assign tags to routes received from bgp. It searched again and found that the next hop address of i55.55.55/32 is 192.168.45.5. Similarly, looking up the routing table again and finally found that 4.4.4.4 is an IGP route. R3 assigned a 301 tag to R2 to 4.4.4.4.4. At this time, the most shameless thing happened. R2 copied this tag to the CEF table about 55.55.55.55 and 192.168.45.0/24, and pushed into the tag, that is, all bgp routes received from 192.168.45.5 have this behavior, as shown below:

r2#show ip cef detail

4.4.4.4/32, version 10, epoch 0, cached adjacency to Serial2/0
0 packets, 0 bytes
  tag informationset, shared
    local tag: 201
    fast tag rewrite with Se2/0, point2point, tags imposed: {301}
  via 192.168.23.3, Serial2/0, 1 dependency
    next hop 192.168.23.3, Serial2/0
    valid cached adjacency
    tag rewrite with Se2/0, point2point, tags imposed: {301}

55.55.55.55/32, version 19, epoch 0, cached adjacency to Serial2/0
0 packets, 0 bytes
  tag information from 4.4.4.4/32, shared
    local tag: 201
    fast tag rewrite with Se2/0, point2point, tags imposed: {301}
  via 192.168.45.5, 0 dependencies, recursive
    next hop 192.168.23.3, Serial2/0 via 192.168.45.0/24
    valid cached adjacency
    tag rewrite with Se2/0, point2point, tags imposed: {301}

192.168.45.0/24, version 18, epoch 0, cached adjacency to Serial2/0
0 packets, 0 bytes
  tag information from 4.4.4.4/32, shared
    local tag: 201
    fast tag rewrite with Se2/0, point2point, tags imposed: {301}
  via 4.4.4.4, 1 dependency, recursive
    next hop 192.168.23.3, Serial2/0 via 4.4.4.4/32
    valid cached adjacency
    tag rewrite with Se2/0, point2point, tags imposed: {301}

------------------------------------

The router will not assign tags to routes received from bgp, so you can't see the tag bindings for 55.55.55.55/32 here
r2#sho tag tdp bind     
  tib entry: 2.2.2.2/32, rev 4
        local binding:  tag: imp-null
        remote binding: tsr: 3.3.3.3:0, tag: 300
  tib entry: 3.3.3.3/32, rev 6
        local binding:  tag: 200
        remote binding: tsr: 3.3.3.3:0, tag: imp-null
  tib entry: 4.4.4.4/32, rev 8
        local binding:  tag: 201
        remote binding: tsr: 3.3.3.3:0, tag: 301
  tib entry: 192.168.12.0/24, rev 2
        local binding:  tag: imp-null
  tib entry: 192.168.23.0/24, rev 10
        local binding:  tag: imp-null
        remote binding: tsr: 3.3.3.3:0, tag: imp-null
  tib entry: 192.168.34.0/24, rev 12
        local binding:  tag: 202
        remote binding: tsr: 3.3.3.3:0, tag: imp-null

When R3 receives the mpls packet with 301 tag, it will bounce the last jump according to its tag forwarding table. The next jump is 4.4.4.4/32, and 4.4.4.4/32 already has internet routes, so it can forward normally

r3#show tag-switching forwarding-table
Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop   
tag    tag or VC   or Tunnel Id      switched   interface             
300    Pop tag     2.2.2.2/32        4061       Se2/0      point2point 
301    Pop tag     4.4.4.4/32        4457       Se1/0      point2point 

At this time, there is no 55.55.55.55/32 route on R3.
r3#sh ip rou
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     2.0.0.0/32 is subnetted, 1 subnets
O       2.2.2.2 [110/65] via 192.168.23.2, 00:28:23, Serial2/0
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     4.0.0.0/32 is subnetted, 1 subnets
O       4.4.4.4 [110/65] via 192.168.34.4, 00:28:23, Serial1/0
C    192.168.23.0/24 is directly connected, Serial2/0
C    192.168.34.0/24 is directly connected, Serial1/0

This is to use mpls to avoid the routing black hole problem of bgp. It should be made clear? ^_^

Article entry: csh     Editor in charge: csh