Distribute BGP routes into OSPF

Answered Question
May 30th, 2008

I have an edge router that is connected to Verizon's network.


I have BGP on this router configured to advertise one of my internal networks (10.2.7.0) to

Verizon:


router ospf 1

log-adjacency-changes

passive-interface Serial1/0

network 0.0.0.0 255.255.255.255 area 0

!

router bgp 1

no synchronization

bgp log-neighbor-changes

network 10.2.7.0 mask 255.255.255.0

neighbor 6.1.2.9 remote-as 65000

no auto-summary




I am receiving the necessary routes from Veizon and they can see my subnet 10.2.7.0.



From this same router I need to distribute the routes learned from Verizon's BGP, to my

internal network, but I only need to advertise these BGP routes to my internal network and none other:


B 172.16.2.0 [20/0] via 6.1.2.9, 00:09:00

B 172.16.2.0 [20/0] via 6.1.2.9, 00:09:00

B 172.16.2.128 [20/0] via 6.1.2.9, 00:09:00

B 172.16.2.128 [20/0] via 6.1.2.9, 00:09:00


It would also be desirable to filter the OSPF routes I am seeing in my route table on this router route table with

the exception of a few subnets I need.


Is it possible to distribute only the BGP routes I have defined above into my internal

OSPF process (I don't know how this would be done), while at the same time filtering this

routers route table with a ditribute list with something like the below?:


distribute-list 10 in GigabitEthernet0/0


access-list 10 permit 172.16.2.0 0.0.0.127

access-list 10 permit 172.16.2.128 0.0.0.127

Correct Answer by lamav about 8 years 9 months ago

Can you post the complete configs and the output of a


show ip bgp neighbors 6.1.2.9 advertised-routes

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 5 (6 ratings)
Loading.
lamav Fri, 05/30/2008 - 17:46

One way of redistributing BGP prefixes into OSPF is to do it in the following manner.


router ospf 1

router-id 10.10.10.225

redistribute bgp 1 metric 50 metric-type 2 subnets route-map REDISTRIBUTE.BGP.NETS


router bgp 1

router-id 10.10.10.225


route-map REDISTRIBUTE.BGP.NETS permit 10

description Redistribute BGP into OSPF

match ip address prefix-list REDISTRIBUTE



ip prefix-list REDISTRIBUTE description Filter Redistributed BGP Prefixes

ip prefix-list REDISTRIBUTE seq 5 permit 172.16.2.0/25

ip prefix-list REDISTRIBUTE seq 10 permit 172.16.2.128/25


Take note of the matching router IDs for the bgp and ospf processes. They must match.


HTH


Victor

wilson_1234_2 Sat, 05/31/2008 - 05:49

Victor,


This worked as you said to distribute the BGP network into my OSPF network, but It looks like Verizon is no longer able to see my internal subnet I am advertising to them.


I can see their subnets that they are advertising to me, but they will not return ICMP back when sourced from my advertised subnet (etherent interface of edge router)


When sourced from the serial interface of the edge router, Verizon will return ICMP.


Would giving my BGP process a router-id affect the way Verizon sees my advertised subnet??

Correct Answer
lamav Sat, 05/31/2008 - 06:04

Can you post the complete configs and the output of a


show ip bgp neighbors 6.1.2.9 advertised-routes

wilson_1234_2 Sat, 05/31/2008 - 06:38

I found it.


I had a static route in the config, because I am advertising a 24 bit subnet mask and the ethernet inteface is a 16 bit mask.


I had removed this route by mistake last night.


But your suggestion is working as you had suggested.


I am trying to give you five more points, but it does not seem to be taking it just now.


I will give five more points once the dang thing will let me.


I really appreciate your assistance.

lamav Sat, 05/31/2008 - 06:45

OK, cool!


Thanks for your generosity. :-)


Victor

wilson_1234_2 Sat, 05/31/2008 - 11:55

Victor,


Can you explain what has been done?


For example:


outer ospf 1

router-id 10.10.10.225

redistribute bgp 1 metric 50 metric-type 2 subnets route-map REDISTRIBUTE.BGP.NETS


What made you decide upon the metric of 50?

What are "metric-type 2" ?


Also:

ip prefix-list REDISTRIBUTE seq 5 permit 172.16.2.0/25

ip prefix-list REDISTRIBUTE seq 10 permit 172.16.2.128/25


Is "seq 5 or 10" do the different subnets have to be given a sequence number? What is the significance of sequence?


Why do the Router IDs have to match?

lamav Sat, 05/31/2008 - 12:32

Hi:


When you redistribute one routing protocol into another, a seed metric (default metric) must be defined, either by the administrator or by the router's IOS, as occurs when redistributing into OSPF. In that case, the default seed metric is 20, unless defined as some other quantity by the administrator.


A seed metric is required so that the receiving IGP can allocate a metric that it can understand. OSPF uses cost as a metric.


A type 2 (E2) external route is one in which the initial cost of the route is introduced into the receiving IGP and does NOT get incremented, regardless of the path a packet takes to get to the destination network. In other words, the redistributing router is saying, "Hello, everyone. I have a route to 172.16.2.0/25 with a cost of 50." That type 2 cost will not change. It will always be 50. So, whether a packet takes 8 hops and traverses 8 interfaces (each with its own cost) to get to the advertising router, or whether a packet traverses 2 interfaces to get to the advertising router, the cost to the destination network will always be 50. A Type 1 (E1) external route has an initial cost that is incremented by the cost of each interface that the packet must traverse -- so, its additive. By default, routes redistributed into OSPF are tagged as E2.


Now, I didn't have to select a metric for the redistributed routes for 2 reasons:


1.) The default cost of 20 would have been acceptable.


2.) With only one ASBR advertising that external network, the cost is irrelevant because there is no comparable route to the same destination network. Everyone has to go to that advertising ASBR -- period.


I also did not have to define the external route type as E2 because, as I said, it is defined as such by default.


I defined the seed metric and the type for you so that you can understand what information is needed for redistributed routes. Why did I select 50 as a default cost, in particular? Just a random choice other than the default of 20.


Moreover, defining a seed metric and classifying the external route as either type 1 or type 2 really comes into play when you have more than one ASBR advertising the external network. You can make one path more desirable than the other by adjusting the metric and classifying it as E1 or E2.


Lasltly, if the administrator does not assign sequence numbers to the lines of a prefix list, the Cisco IOS will assign them automatically, starting at 5 and incrementing by 5. The purpose is to allow flexibility and facilitate the injection of more configuration lines in the prefix list without having to write it all over again.


HTH


Victor



wilson_1234_2 Sat, 05/31/2008 - 13:32

Victor,


Thank you.


Outstanding explanation!


What about the Router ID on BGP and OPSF.


What was the reason for:


1. Assigning BGP a router ID.

2. Signigicance of the matching OSPF+BGP router ID

lamav Sat, 05/31/2008 - 13:41

After proof-reading my previous post for clarity, I noticed that you had a question regarding router IDs and the requirment that they be the same on the BGP-speak OSPF ASBR router.


The interactions between BGP and OSPF, including bi-directional redistribution, are explicity detailed in RFC 1364.


http://www.ietf.org/rfc/rfc1364.txt


In short, the requirement has its roots in the scenario in which 2 "Bi-lingual" ASBRs are injecting eBGP-learned routes into the OSPF domain, and then advertising it through iBGP to another eBGP speaker in the same AS, who will in turn advertise out to another AS.


For the purpose of our discussion:


ASBRs who inject external routes are ASBR#1 and ASBR #2. The eBGP speaker who will advertise the route to another AS is eBGP #1.


eBGP speaker #1 (who will learn of the external route through internal OSPF convergence, after it gets injected by ASBRs 1 and 2) will learn the router ID of the ASBR whose route it chooses to use, and then must bind that router ID to the router ID of the corresponding router's BGP advertisement so that it can create the correct transitive attribute (AS_Path, in particular) to send to an eBGP peer in another AS.


Basically, eBGP router#1 will say "The OSPF route for the external network (172.16.2.0/25), which was originally injected into the OSPF domain by router 10.10.10.225 (ASBR #1), has the lowest metric. Therefore, I will use his route path to forward packets to 172.16.2.0/25. Oh, but what is that ASBR's AS_Path (the transitive attribute that must be advertised to the eBGP speaker)? I can tell if I look in my BGP table and cross reference the router IDs from the OSPF LSA and the BGP table."


This is how I understand it.


HTH


Victor

wilson_1234_2 Mon, 06/02/2008 - 17:24

Victor,


In your description of E1 and E2 routes:


"A type 2 (E2) external route is one in which the initial cost of the route is introduced into the receiving IGP and does NOT get incremented, regardless of the path a packet takes to get to the destination network. In other words, the redistributing router is saying, "Hello, everyone. I have a route to 172.16.2.0/25 with a cost of 50." That type 2 cost will not change. It will always be 50. So, whether a packet takes 8 hops and traverses 8 interfaces (each with its own cost) to get to the advertising router, or whether a packet traverses 2 interfaces to get to the advertising router, the cost to the destination network will always be 50. A Type 1 (E1) external route has an initial cost that is incremented by the cost of each interface that the packet must traverse -- so, its additive. By default, routes redistributed into OSPF are tagged as E2."



Is it possible to force a route to be distributed as a type 1 route (I believe it is) if the need is to have the cost increment depending how many hops to a particular destination, if I wanted to use that as a way to control the path?



Also, my current need of the distributions is this:


HQ has edge router-->IP2IP Gateway-->inside

DR has edge router-->DRIP2IP Gateway-->inside


The edge routers are preferring the BGP(AD 20) path through Verizon's network to the opposing IP2IP gateway, rather than internally via OSPF (AD 110) which is per normal.


Is there a way for me to increase the AD of the BGP routes on the edge routers(learned from Verizon), so I can force the preferred path from HQ edge to DR IP2IP gateway through OSPF intrnally?

Actions

This Discussion