Redistribution of named and tagged static routes

Redistribution of named and tagged static routes

Redistribute named and Tagged Static routesI always name my IOS static routes as a best practise. However I hit a syntax issue last week when I tried to combine the named static with a tag, then redistributing that tagged static route into OSPF. If you have issues redistributing a ‘named and tagged static’ then this may be the post for you.
The simplified config snippet below is configured on SW1 (cisco 3750X). This config will match all static routes tagged with ‘200’ and redistribute them into OSPF. I could have avoided this whole issue if I used a prefix list to match the routes, but I think tag-and-match is a more efficient and less-error prone approach.

1
2
3
4
5
6
7
8
router ospf 2 vrf FOO
redistribute static subnets route-map RM_VRF_FOO_STATIC2OSPF
!
route-map RM_VRF_FOO_STATIC2OSPF permit 10
match tag 200
set metric 20
!
route-map RM_VRF_FOO_STATIC2OSPF deny 10000

Then I added a static route with the name argument first and the tag second. I don’t show it here but this is valid syntax for routing and this route does appear as a valid route in the VRF routing table.

1
ip route vrf FOO 10.2.0.0 255.255.0.0 10.1.40.1 name Foo_Via_Bar tag 200

But when I check for the 10.2.0.0/16 Type-5 LSA in the database I don’t see my locally originated static.

1
2
3
4
SW11#sh ip ospf database | b Type-5
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
10.1.0.0 192.168.1.1 1400 0x80000005 0x0083F7 200

But when I modify the static route to add the tag first and the name second….

1
ip route vrf FOO 10.2.0.0 255.255.0.0 10.1.40.1 tag 200 name Foo_Via_Bar

The redistribution code can match the tag, and create a Type-5 for it. You can see the redistributed route 10.2.0.0/16 on line 5 below.

1
2
3
4
5
SW1#sh ip ospf database | b Type-5
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
10.2.0.0 192.168.1.2 5 0x80000001 0x00704A 200  ! YAY
10.1.0.0 192.168.1.1 1744 0x80000005 0x0083F7 200

Sherpa Summary

It’s a simple lesson, but easy to forget. If you’re tagging static routes and naming them, put the tag before the name.
Always check for the effect you want, not just that the configuration looks right.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.