OSPF External Routes (E2) are advertised into OSPF Autonomous System with a particular cost and the cost is not changed throughout the AS. The routes are learned via redistribution of other routing protocol or static route or a connected subnet. The router performing redistribution is the Autonomous System Border Router (ASBR). By default, all OSPF routes learned via redistribution are of E2 type.
Redisribution of OSPF Routes (E1 or E2) into BGP can be performed via two ways, this document focus on E2 routes.
b) Using Route-Map Match Statement "match route-type external type-2"
Using Route Maps gives more felxibility to the user, as one can match the routes based on different criteria (access-list, tag).
Understanding of OSPF Routing Protocol
Understanding of Border Gateway Protocol (BGP)
In this document the focus is on route-map to match the E2 types routes and then redistributing them into other routing system. Three Routers, R1, R2 and R3 are connected via Serial Interface. Router R1 and R2 are participating in OSPF Area 0 while Router R2 and R3 are forming IBGP peering under AS 100.
On R1, Loopback Interfaces (Lo 2 and Lo 3), are redsitributed in OSPF. A route-map "connected is configured" to match the specified interfaces and then redistributed via command "redictribute connected route-map connected". On router R2 these loopback prefixes are learned of type E2. On R2, a route-map (route-map E2OSPF in this document, see configuration on Router R2) is configured to match only the E2 type prefixes and redistribiuted into BGP system.
Note: All configurations are tested on C3745 router operating on IOS verison 12.4(15)T14.