How does the BGP network statement work?

Hello,

I’m using the following topology and I have configured a static route on R3 and R4 for 5.5.5.5/32, but on R4 with AD 250. Between R3 and R4 the iBGP session is up and I can see that I’m advertising the prefix 5.5.5.5/32. Why does R4 choose that static route with AD 250, instead of the iBGP route with AD 200?

Thanks a lot.

    R3#show ip bgp neighbors 10.0.0.4 advertised-routes 
    BGP table version is 12, local router ID is 192.168.0.3
    Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, 
                  r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter, 
                  x best-external, a additional-path, c RIB-compressed, 
    Origin codes: i - IGP, e - EGP, ? - incomplete
    RPKI validation codes: V valid, I invalid, N Not found

         Network          Next Hop            Metric LocPrf Weight Path
     *>  5.5.5.5/32       10.0.0.10                0         32768 i
     *>  10.0.0.0/24      0.0.0.0                  0         32768 i

    Total number of prefixes 2 
 R3#show ip bgp 5.5.5.5
    BGP routing table entry for 5.5.5.5/32, version 12
    Paths: (2 available, best #1, table default)
      Advertised to update-groups:
         8          11        
      Refresh Epoch 1
      Local
        10.0.0.10 from 0.0.0.0 (192.168.0.3)
          Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
      Refresh Epoch 1
      Local
        10.0.0.10 from 10.0.0.4 (192.168.0.4)
          Origin IGP, metric 0, localpref 100, valid, internal
R3#show ip route 5.5.5.5
Routing entry for 5.5.5.5/32
  Known via "static", distance 1, metric 0
  Advertised by bgp 100
  Routing Descriptor Blocks:
  * 10.0.0.10
      Route metric is 0, traffic share count is 1
    R4#show ip bgp 5.5.5.5
    BGP routing table entry for 5.5.5.5/32, version 6
    Paths: (2 available, best #2, table default)
      Advertised to update-groups:
         14         15        
      Refresh Epoch 1
      Local
        10.0.0.10 from 10.0.0.3 (192.168.0.3)
          Origin IGP, metric 0, localpref 100, valid, internal
      Refresh Epoch 1
      Local
        10.0.0.10 from 0.0.0.0 (192.168.0.4)
          Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best
  R4#show ip route 5.5.5.5
    Routing entry for 5.5.5.5/32
      Known via "static", distance 250, metric 0
      Advertised by bgp 100
      Routing Descriptor Blocks:
      * 10.0.0.10
          Route metric is 0, traffic share count is 1

Hi Lukas,

I’m guessing you use redistribute static on both R3 and R4?

R4 has two entries for 5.5.5.5/32 in the BGP table. The first one from R3:

        10.0.0.10 from 10.0.0.3 (192.168.0.3)
          Origin IGP, metric 0, localpref 100, valid, internal

The second one from R4 (because of redistribute static):

        10.0.0.10 from 0.0.0.0 (192.168.0.4)
          Origin IGP, metric 0, localpref 100, weight 32768, valid, sourced, local, best

The second route shows best so out of these two BGP routes, that’s the one it wants to install.

However, this route got there because of the redistribute static command so it will never be used by R4. That’s why it installs the static route.

You can get funky results with this btw. Try resetting BGP on R3 and R4 one after another. Depending on the order, it’s possible that they learn the route from each other and (temporarily) install either the static or BGP route.

Rene