Redistribution using tags

Tags provide an alternative method for redistributing routes. For instance, you can set tags when redistributing routes into a domain and then use those tags for matches when redistributing those routes out of the domain. In the following example, tags are set as the routes pass through the North router from the northern RIP domain to the OSPF domain, and those tags are used for matching when the routes pass out of the OSPF domain through the South router to the southern RIP domain.

Establish prefix lists on the North router to separate the "odd" and "even" routes:

ip prefix-list "Odds" seq 5 permit 10.1.11.1 255.255.255.0 ge 24 le 24
ip prefix-list "Odds" seq 10 permit 10.1.13.1 255.255.255.0 ge 24 le 24

ip prefix-list "Evens" seq 5 permit 10.1.12.1 255.255.255.0 ge 24 le 24
ip prefix-list "Evens" seq 10 permit 10.1.14.1 255.255.255.0 ge 24 le 24

Then set up a route map with separate sequences to tag the odd and even routes:

route-map "TagIn" permit seq 10
   match ip address prefix-list "Odds"
   set tag 1
   exit
route-map "TagIn" permit seq 20
   match ip address prefix-list "Evens"
   set tag 2
   exit

Set up a separate route map to match the connected routes, and assign the same tag value you used for the odd routes. This allows you to propagate both the odd and the connected routes, but not the even routes, to the southern RIP domain.

route-map "TagConn" permit seq 10
   match source-protocol connected
   set tag 1
   exit

Redistribute the routes to the OSPF domain using the route maps:

router ospf
   area backbone
   redistribute connected route-map "TagConn"
   redistribute rip route-map "TagIn"
   exit
On the South router set up a route map with three sequences:
  • One to permit routes with tag values of 1

  • One to deny routes with tag values of 2

  • One to permit OSPF routes (this propagates all the routes from the OSPF domain

The route map looks like this:

route-map "TagOut" permit seq 10
   match tag 1
   exit
route-map "TagOut" deny seq 20
   match tag 2
   exit
route-map "TagOut" permit seq 30
   match source-protocol ospf

This arrangement permits the odd routes from the northern RIP domain and the RIP routes that were connected to the North router. It denies the even routes from the northern RIP domain, and it permits the OSPF routes. The route table from the Southeast router shows the results:

Southeast(config)# show ip route

IP Route Entries 

 Destination     Gateway         VLAN Type      Sub-Type   Metric     Dist. 
 --------------- --------------- ---- --------- ---------- ---------- ----- 
 10.1.11.0/24    10.2.21.1       21   rip                  2          120
 10.1.13.0/24    10.2.21.1       21   rip                  2          120
 10.1.15.0/24    10.2.21.1       21   rip                  2          120
 10.1.16.0/24    10.2.21.1       21   rip                  2          120
 10.2.21.0/24    VLAN21          21   connected            1          0
 10.2.22.0/24    VLAN22          22   connected            1          0
 10.2.23.0/24    VLAN23          23   connected            1          0
 10.2.29.0/24    10.2.21.1       21   rip                  2          120
 10.3.31.0/24    10.2.21.1       21   rip                  2          120
 10.3.32.0/24    10.2.21.1       21   rip                  2          120
 10.3.33.0/24    10.2.21.1       21   rip                  2          120
 10.3.34.0/24    10.2.21.1       21   rip                  2          120
 10.3.37.0/24    10.2.21.1       21   rip                  2          120
 127.0.0.0/8     reject               static               0          0
 127.0.0.1/32    lo0                  connected            1          0