Sub topic 15
Redistributing Routes Between Sources
Redistribution is how a router takes routes it knows from one source and advertises them into another routing protocol. This chapter assumes you know longest-prefix match, static routes, administrative distance (AD), metrics, and the basics of OSPF and RIP from earlier chapters. You should also be able to read Cisco IOS configuration.
Why redistribution exists
A routing protocol only advertises routes that it learned itself or that come from interfaces it runs on. Routes from other sources stay invisible to it. A router can hold routes from several sources at once:
- Connected networks.
- Static routes.
- OSPF routes.
- RIP routes.
OSPF will not announce a RIP-learned route to its neighbors, and RIP will not announce an OSPF-learned route. Without redistribution, each routing domain has no path to the others.
Common reasons to redistribute:
- Merging networks after an acquisition, where one side runs RIP and the other runs OSPF.
- Migrating from one protocol to another in stages.
- Advertising static routes, such as a default route or a route to a partner network, into a dynamic protocol so you configure them in one place.
- Injecting routes from a protocol that does not run on every router.
Redistribution works only on the router where you configure it, called the boundary router. It reads entries from its routing table that came from the source, converts them to the destination protocol's format, and advertises them.
What happens to a route when it is redistributed
Three things change, and each one causes a common error.
The metric does not carry over
Metrics are protocol-specific. RIP counts hops, and OSPF sums link costs. A RIP metric of 3 means nothing to OSPF. The boundary router must assign a new metric, called a seed metric, to each redistributed route.
- RIP has no default seed metric for redistributed routes. If you do not set one, RIP treats the metric as infinite (16) and the routes are not advertised.
- OSPF assigns a default seed metric of 20 to most redistributed routes. It uses 1 for routes from BGP.
The route is marked as external
OSPF tags redistributed routes as external. Type 2 (E2) is the default. An E2 route keeps the same cost across the OSPF domain, so routers further away do not add their own internal path cost. Type 1 (E1) adds the internal cost to reach the boundary router, which lets routers choose the closest exit when there are several boundary routers.
The administrative distance changes
Administrative distance is evaluated on each router, using the AD of the protocol that installed the route there. A static route on the boundary router has AD 1 on that router. After redistribution into OSPF, a neighbor sees it as an OSPF external route with AD 110.
| Source on the boundary router | AD on the boundary router | AD on a neighbor after redistribution into OSPF |
|---|---|---|
| Connected | 0 | 110 (OSPF external) |
| Static | 1 | 110 (OSPF external) |
| RIP | 120 | 110 (OSPF external) |
The last row has consequences. Suppose a router learns the same prefix from RIP (AD 120) and from OSPF as an external route (AD 110). It prefers the OSPF route, even if the RIP path is shorter. Redistribution can quietly change which path traffic takes.
Configuring redistribution
Static routes into OSPF
This is the most common case. A static route on the boundary router is announced to every OSPF neighbor.
! Cisco IOS: static route on the boundary router
ip route 172.16.0.0 255.255.0.0 192.168.1.2
router ospf 1
router-id 1.1.1.1
network 10.1.0.0 0.0.255.255 area 0
! "subnets" is needed so that subnetted networks are included
redistribute static subnetsWithout the subnets keyword, classful behavior applies and OSPF redistributes only classful networks. Most newer IOS versions require or imply subnets, but write it explicitly. To announce a default route into OSPF, use default-information originate instead. Plain redistribute static does not include 0.0.0.0/0.
Two-way redistribution between RIP and OSPF
! Cisco IOS: boundary router R1
router ospf 1
router-id 1.1.1.1
network 10.1.0.0 0.0.255.255 area 0
redistribute rip subnets metric 50 metric-type 1
router rip
version 2
network 10.3.0.0
no auto-summary
redistribute ospf 1 metric 3The OSPF side assigns cost 50 and external type 1. The RIP side assigns a hop count of 3 to every OSPF route. A fixed metric is blunt, because RIP routers then see all OSPF destinations as equally far away.
The main risk: routing loops
With a single boundary router, redistribution is safe. Trouble begins with two or more boundary routers redistributing in both directions. A route can leave RIP, enter OSPF, and come back into RIP through the second boundary router, now with a better metric or AD than the original.
The result can be a routing loop or a suboptimal path. The usual defenses are:
- Tag routes as they are redistributed, then deny those tags when redistributing in the other direction.
- Filter by prefix, redistributing only the networks that belong to the source domain.
- Use one boundary router per pair of domains, or use one-way redistribution plus default routes.
- Set the metric deliberately, not by accident.
Tag-based loop prevention
This example marks routes that came from OSPF when they enter RIP. The second boundary router refuses to send routes with that tag back into OSPF.
! Cisco IOS: on both boundary routers
route-map OSPF-TO-RIP permit 10
set tag 110
set metric 3
route-map RIP-TO-OSPF deny 10
match tag 110
route-map RIP-TO-OSPF permit 20
set metric 50
router rip
redistribute ospf 1 route-map OSPF-TO-RIP
router ospf 1
redistribute rip subnets route-map RIP-TO-OSPFAny route that passed through OSPF carries tag 110 when RIP advertises it. RIP version 2 carries route tags, and the second router uses the tag to block a return trip. Use tags that are unique to the domain pair, and document them.
Other gotchas
- Lost information: Redistributed routes lose their original metric, so neighbors cannot tell whether a route is near or far in the source domain.
- Table growth: Redistributing a large table, such as BGP into OSPF, floods every router with external routes. Summarize or filter first.
- Connected networks:
redistribute connectedadvertises every connected interface network, including ones you did not intend to share, such as management subnets. Filter with a route map. - Missing source routes: A router can redistribute only routes that are in its routing table as the best path from that source. If a static route is overridden by a better route from another protocol, it is not redistributed.
- Convergence: Redistributed routes converge as slowly as the slower protocol involved. A flap in a RIP domain may appear as repeated external route changes in OSPF.
Verifying redistribution
Check on the boundary router first, then on a router inside each domain.
! Cisco IOS
show ip protocols
show ip route ospf
show ip route 10.3.0.0
show ip ospf database external
show ip route ripshow ip protocolslists which sources a protocol redistributes and which route map applies.- On an OSPF router, redistributed routes are marked
O E1orO E2inshow ip route. show ip route 10.3.0.0shows the AD and metric of the route that won, which tells you which source was chosen.show ip ospf database externallists the external LSAs and the router that advertised them.
If a route is missing, work through the chain: is it in the boundary router's table, does the redistribute statement name the right source, does a route map deny it, and does the destination protocol have a seed metric?
When to avoid redistribution
Redistribution is a patch for a boundary, not a design goal. If you can run one protocol everywhere, do that. If you must connect two domains, prefer these patterns, in order:
- One-way redistribution of a few specific prefixes, plus a default route pointing back.
- Static routes on the boundary router, redistributed with a route map.
- Two-way redistribution at a single router, with filtering.
- Two-way redistribution at several routers, only with tags and testing of failure cases.
Exercise
Router R1 redistributes RIP into OSPF but you see no RIP-learned routes on OSPF neighbors. The configuration line is redistribute rip. Name two likely causes.
Show answer
Either the subnets keyword is missing, so OSPF skips subnetted networks, or the RIP routes are not in R1's routing table as best routes. Also check that the router has RIP routes at all with show ip route rip. A route map that denies the prefixes is another possible cause.
Exercise
A neighbor in the OSPF domain learns 10.3.0.0/16 from OSPF as an external route and also from RIP directly. Which route does it install, and why?
Show answer
It installs the OSPF external route, because OSPF has AD 110 and RIP has AD 120, and the lower AD wins regardless of the metrics. The RIP route is a backup that is used only if the OSPF route disappears.
Exercise
Why does a RIP domain advertise nothing after you add redistribute ospf 1 with no metric under router rip?
Show answer
RIP has no default seed metric. Without a metric, the redistributed routes are treated as unreachable (infinite, 16 hops). Add metric 3 to the command, or set a metric in a route map.