=======Routing Loops with More than Two Routing Domains and Per-Route AD settings=======
===Per-Route AD Settings===
* The problem with suboptimal path routing and routing loops can be resolved by changing the per-route AD on ASBRs.
* With the **distance** command, the AD is usually changed for all the internal and/or external routes; sometimes this may not resolve the issue for the above problem.
* To change the AD value for the selective routes, use the following command:
* **distance** distance ip-adv-router wc-mask [acl-number/name]
* In this command, the required parameters match the neighboring router that advertises a route.
* Optionally, the **distance** command can also refer to an ACL. If included, that router compares the ACL to the prefix/length of each route learned from any matched neighbors and uses the listed AD only for routes permitted by the ACL.
* Example OSPF:
R19(config)# ip access-list 2 permit 1.18.18.0 0.0.0.255
R19(config)# router ospf 1
R19(config-router)# distance 98 0.0.0.18 0.0.0.0 2
R19# show ip route ospf ## Check if AD changed for specific route ##
* Example EIGRP
R20(config)# router eigrp 100
R20(config-router)# network 88.0.0.0
R19(config)# router eigrp 100
R19(config-router)# distance 88 20.19.20.20 0.0.0.0 3 # Only applies to iEIGRP routes from ACL 3 #
R19# show ip route eigrp # Look for the 88.88.88.0/24 and make sure it has an AD of 88 #
===Preventing Routing Loops by Filtering Using Tag===
* This problem can be resolved by doing route filtering on ASBRs connecting IGP2 and IGP3.
* Filtering can be done in two ways: with per subnet filtering, or by using tags with routes.
* Performing filtering with per subnet requires long ACL/Prefix-list configurations.
* This method also has a higher chance of human error.
==Using Tags for Route Filtering==
* A route tag is a unitless 32-bit integer that most routing protocols can assign to any given route.
* It can be assigned by a route-map referenced by a routing protocol **distribute-list** or **redistribute** command.
* The tag value follows the route advertisement, even through the redistribution process.
*The tag value is commonly used to identify routes, to do filtering, and to prevent routing loops.
* The concept is simple: One router sets the tag, the route (along with the tag) get advertised as per design, and then a certain router can match that route based on the tag value and either do filtering or change some attributes of the routes.
* The tag is set by using the command **set tag** in a route-map entry.
* Example
R20(config)# router rip
R20(config-router)# version 2
R20(config-router)# no auto-summary
R20(config-router)# network 18.0.0.0
R20(config-router)# redistribute ospf 1 metric 9
!
R18(config)# router rip
R18(config-router)# version 2
R18(config-router)# no auto-summary
R18(config-router)# network 18.0.0.0
R18(config-router)# redistribute ospf 1 metric 9
!
R18(config)# access-list 1 permit 2.2.2.0 0.0.0.255
R18(config)# route-map Set-Tag permit 10
R18(config-route-map)# match ip add 1
R18(config-route-map)# set tag 888
R18(config)# router rip
R18(config)# redistribute ospf 1 metric 9 route-map Set-Tag
!
R18# show ip route 2.2.2.0 # Look for the tag #
* When EIGRP is redistributed into OSPF, the tag from EIGRP is preserved.
* When EIGRP is redistributed into RIP, the tag from EIGRP is deleted and has to be added back on.