Redistributing Routes with BGP


You want to redistribute routes between an IGP and BGP.


When connecting two or more IGPs using BGP, you sometimes need to configure redistribution between the IGP and BGP on both routers. To make the example more interesting, we will assume that we need to connect an EIGRP network to an OSPF network using a pair of BGP routers.

The first router redistributes routes from BGP into OSPF:

Router1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router1(config)#router ospf 100
Router1(config-router)#network area 0
Router1(config-router)#redistribute bgp 65500 metric 500 subnets
Router1(config)#router bgp 65500
Router1(config-router)#neighbor remote-as 65520

And this is the configuration for the router that redistributes BGP routes into EIGRP:

Router2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router2(config)#router eigrp 99
Router2(config-router)#redistribute bgp 65520 metric 500 10 255 1 1500
Router2(config)#router bgp 65520
Router2(config-router)#neighbor remote-as 65500



Before we say anything about this recipe, we need to stress that redistribution with BGP is often a very messy business. The example specifically shows using BGP to handle routing between two IGPs rather than redistribution into the public Internet, because this technique is only really relevant in a large enterprise network. Even here, it's easy to create routing loops, particularly when redistributing from BGP into an IGP and then back out into BGP. This is why we have actually chosen to distribute from BGP into the other protocols, rather than full two-way redistribution. We will discuss two-way redistribution in a moment.

For Internet connections, we strongly recommend against redistributing routes from BGP into the IGP. This is because it is too easy to inadvertently wind up distributing tens of thousands of Internet routing prefixes into your IGP. And, when passing IGP routing information to the Internet, it is better to pass a few summary routes using network statements, as we have done in the above example, than to directly redistribute IGP prefixes.

In addition, there is a huge danger when you redistribute BGP routes from the Internet, into an IGP, and then back into BGP and onto the Internet. Unless you carefully filter routes, or unless your ISP filters for you, you will wind up sending routes back into the Internet with very short AS Paths that originate in your network. This could reroute the entire Internet through your IGP, which would be a Bad Thing.

However, BGP isn't just used on the public Internet. Many large enterprise networks also use BGP for interconnecting IGPs. In this case, although you have to redistribute routes from BGP into the IGP, it may not be necessary to redistribute IGP routes into BGP. So, in the above example, we have actually only used one-way redistribution from the BGP into the IGP, but not the other way around. Instead, we have relied on network statements to summarize the IGP routes into BGP:

Router1(config)#router bgp 65500
Router1(config-router)#neighbor remote-as 65520

If you need BGP to advertise a large number of IGP routes, you can use as many network statements as are necessary to accomplish this. Note that before IOS Version 12.0, you could configure a maximum of 200 network statements. However, Cisco has now removed this restriction.

Having said all of this, it is possible to redistribute prefixes from the IGP into BGP. Two-way redistribution can be convenient when you want to use BGP to connect two IGPs that use overlapping address ranges. This might happen, for example, if a single IGP became too large and needed to be split for stability reasons.

We have already discussed how to redistribute foreign routing protocols into both EIGRP and OSPF in Chapters 7 and 8, respectively, so we will focus instead on the redistribution of these protocols into BGP here.

The work is all done by a simple redistribute command in the BGP configuration clause. For simple redistribution, all we need to do is specify the IGP protocol and its process ID number:

Router1(config)#router bgp 65500
Router1(config-router)#redistribute ospf 100

However, by default, when you do this, BGP takes the IGP metric and uses it as the BGP metric, also called the MED. BGP distributes this metric with the route. Routers use the lowest metric value to select the best route if two or more BGP routes have the same AS Path length.

This may provide exactly the right behavior, selecting the BGP router that is closest to the IGP destination network. But in some cases you might want to force a particular metric value to ensure that a particular BGP router or link is used when routing to IGP destinations. You can do this most easily by simply setting a default metric for all redistributed IGP routes:

Router2(config)#router bgp 65520
Router2(config-router)#redistribute eigrp 99 metric 500

Although we have only assigned a default metric to the EIGRP routes, you can use the same syntax to give a default metric to the routes redistributed from OSPF.

We also mentioned in Chapters 7 and 8 that you can assign a route tag to external routes in both OSPF and EIGRP. This can be extremely useful when you do lots of redistribution. In particular, suppose that the EIGRP and OSPF sides of this network have a back door connection to one another, redistributing part or all of their routing tables. In this case, we will need to restrict which routes we redistribute into BGP and suppress all of these back door routes, or we will have routing loop problems.

You can do this with a route map. The simplest case, which is useful for the back door example, is to suppress all external routes when redistributing from the IGP into BGP:

Router2(config)#route-map REDIST deny 10
Router2(config-route-map)#match route-type external
Router2(config)#route-map REDIST permit 20
Router2(config)#router bgp 65520
Router2(config-router)#redistribute eigrp 99 route-map REDIST metric 500

You would need to apply a similar route map at both redistribution points to prevent loops.

However, the route map we just created will match all external routes, not just the external routes due to the back door connection. You might have some redistributed static routes in your IGP, or perhaps some isolated part of your network uses RIP to support legacy equipment. This is where route tags become invaluable. If you have external routes you need to redistribute into BGP, and you know they have a particular tag value such as 123, you can use a slightly more complicated route map like this:

Router2(config)#route-map REDIST permit 5
Router2(config-route-map)#match tag 123
Router2(config)#route-map REDIST deny 10
Router2(config-route-map)#match route-type external
Router2(config)#route-map REDIST permit 20
Router2(config)#router bgp 65520
Router2(config-router)#redistribute eigrp 99 route-map REDIST metric 500

This route map now allows BGP to redistribute all local routes and all external routes that have the tag value 123. But it suppresses all other external routes. You might use a redistribution system like this if you were using BGP to act as a transit between two networks. The router that redistributes routes into BGP from the other network would mark them with this tag value. Then, at this router, we can use this tag to select only these particular external routes for distribution into this particular IGP.

See Also

Chapter 7; Chapter 8

Router Configuration and File Management

Router Management

User Access and Privilege Levels


IP Routing





Frame Relay

Handling Queuing and Congestion

Tunnels and VPNs

Dial Backup

NTP and Time


Router Interfaces and Media

Simple Network Management Protocol





First Hop Redundancy Protocols

IP Multicast

IP Mobility




Appendix 1. External Software Packages

Appendix 2. IP Precedence, TOS, and DSCP Classifications


show all menu

Cisco IOS Cookbook
Cisco IOS Cookbook (Cookbooks (OReilly))
ISBN: 0596527225
EAN: 2147483647
Year: 2004
Pages: 505
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net