BGP route auto-tagging

While reading up on BGP recently, I came across an interesting bit in Routing TCP/IP volume 2: By default (on IOS), BGP-learned routes are automatically tagged with the number of the most recent AS in their AS path. For example, in the following topology, eBGP adjacencies exist between R1 and R2, and between R2 and R3. R3 is redistributing BGP routes into OSPF and advertising them to R4.

topology.png

A route for 172.16.1.0/24 is being generated by R1 and advertised to R2. R2 receives this route as you would expect, with an AS path of "65100".

R2# show ip bgp 172.16.1.0
BGP routing table entry for 172.16.1.0/24, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Flag: 0x820
  Advertised to update-groups:
   1
  65100
    10.0.12.1 from 10.0.12.1 (172.16.1.1)
      Origin IGP, metric 0, localpref 100, valid, external, best

R2 has also automatically tagged the route with this AS number:

R2# show ip route 172.16.1.0
Routing entry for 172.16.1.0/24
  Known via "bgp 65200", distance 20, metric 0
  Tag 65100, type external
  Last update from 10.0.12.1 00:01:55 ago
  Routing Descriptor Blocks:
  * 10.0.12.1, from 10.0.12.1, 00:01:55 ago
  Route metric is 0, traffic share count is 1
  AS Hops 1
  Route tag 65100

When R2 passes the route along to R3, its AS path is expanded to "65200 65100". Like R2, R3 also tags the route with the AS number of the most recent AS in the path (65200):

R3# show ip route 172.16.1.0
Routing entry for 172.16.1.0/24
  Known via "bgp 65300", distance 20, metric 0
  Tag 65200, type external
  Redistributing via ospf 1
  Last update from 10.0.23.2 00:04:46 ago
  Routing Descriptor Blocks:
  * 10.0.23.2, from 10.0.23.2, 00:04:46 ago
  Route metric is 0, traffic share count is 1
  AS Hops 2
  Route tag 65200

Of course, tagging in this manner on BGP routers is redundant, since AS information is already present in the route's AS path. Where it proves convenient, however, is at the next hop, after being redistributed into OSPF.

R4# show ip route 172.16.1.0
Routing entry for 172.16.1.0/24
  Known via "ospf 1", distance 110, metric 1
  Tag 65200, type extern 2, forward metric 10
  Last update from 10.0.34.3 on FastEthernet0/0, 00:00:04 ago
  Routing Descriptor Blocks:
  * 10.0.34.3, from 3.3.3.3, 00:00:04 ago, via FastEthernet0/0
  Route metric is 1, traffic share count is 1
  Route tag 65200

Although R4 does not run BGP and consequently has no knowledge of the route's AS path, the tag containing the AS from which the route was learned is preserved. This is handy to have in case we decide to implement some sort of route filtering or traffic engineering based on source AS within the IGP.

Note that this operation is enabled by default, and is unrelated to the automatic-tag route-map operation, which may be used to propagate route tags in the opposite dorection, from an IGP into BGP.

About the Author

Jeremy Stretch is a freelance networking engineer, instructor, and the maintainer of PacketLife.net. He currently lives in Fairfax, Virginia, on the edge of the Washington, DC metro area. Although primarily an R&S guy, he likes to get into everything, and runs a free network training lab out of his basement for fun. You can contact him by email or follow him on Twitter.

Leave a Comment


Register to comment as a member. You'll look cooler.

Optional; will not be displayed publicly or given out.

No commercial links. Only personal (e.g. blog, Twitter, or LinkedIn) and/or on-topic links, please.
What is the decimal equivalent of 0xA061?