Redistribution from BGP to OSPF

Answered Question
Jan 28th, 2008

I've private AS connected to other private AS's via 2 routers. I received route at first router with as-path 3 and on the second with as-path 4(i've made it for influence traffic). But during redistribution to OSPF all as-path information will be lost. How to preserve that info and use it later in OSPF domain for managing routes?

I have this problem too.
0 votes
Correct Answer by Jon Marshall about 8 years 10 months ago

Ah well, you never said you wanted to do anything with them :)

If you want to set metrics you are better doing it when you redistribute - on the 7200 in our example. So you still use the as-paths to identify the relevant routes but then just set the metric you need.

Jon

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 4.5 (2 ratings)
Loading.
royalblues Mon, 01/28/2008 - 07:36

You can always modify the metric while redistributing so that one router is always preferred inside your ospf domain

Narayan

Jon Marshall Mon, 01/28/2008 - 07:58

Hi

I've just checked this in our lab. The as-path information is preserved as a tag automatically for you. To see this do a

sh ip route "IP subnet" "subnet mask"

on an OSPF route redistributed from BGP and you will see the tag.

You can then use a route-map to match these tags and apply whatever policies you want to them.

Jon

rmv72 Mon, 01/28/2008 - 22:42

Hi

Position tag shows me only last AS number ( Tag 65334)-

pdc-cat6506-obs# sh ip route 10.20.9.0

Routing entry for 10.20.9.0/24

Known via "ospf 1", distance 110, metric 1

Tag 65334, type extern 2, forward metric 1

Last update from 9.9.9.2 on GigabitEthernet5/1, 18:19:09 ago

Routing Descriptor Blocks:

* 9.9.9.2, from 172.22.21.222, 18:19:09 ago, via GigabitEthernet5/1

Route metric is 1, traffic share count is 1

Route tag 65334

pdc-cat6506-obs# sh ip route 10.20.16.0

Routing entry for 10.20.16.0/24

Known via "ospf 1", distance 110, metric 1

Tag 65334, type extern 2, forward metric 1

Last update from 9.9.9.2 on GigabitEthernet5/1, 18:19:22 ago

Routing Descriptor Blocks:

* 9.9.9.2, from 172.22.21.222, 18:19:22 ago, via GigabitEthernet5/1

Route metric is 1, traffic share count is 1

Route tag 65334

Here info from BGP table -

*> 10.20.9.0/24 2.2.2.100 0 65334 i

*> 10.20.16.0/24 2.2.2.201 0 65334 2854 65011 i

dongdongliu Mon, 01/28/2008 - 23:39

Ospf does not understand the attributes of bgp ,you1`d better use metric xx command when redistribute was configured

rmv72 Mon, 01/28/2008 - 23:55

Should i use route policy during redistribution from bgp to ospf where i can match as-path and set metric?

Jon Marshall Mon, 01/28/2008 - 23:59

Hi

This is exactly what i'm trying at the moment in the lab - can't seem to get it working just yet but there is a lot going on in my lab :)

I can't see why this wouldn't work though.

** Edit - okay just got it working, my mistake on the as-path access-list. So yes, you can do this on the router that redistributes between BGP and OSPF. **

Jon

rmv72 Tue, 01/29/2008 - 00:05

Jon, can you post part of config for example?

Jon Marshall Tue, 01/29/2008 - 00:13

Okay, i did not emulate your setup entirely so you will need to use regexs in your as-path access-lists.

R5 -> R1 -> 7200 -> R4

R5 is in BGP AS 20

R1 is in BGP AS 3

7200 is in BGP 10

R5 peers with R1, R1 peers with 7200 and 7200 uses OSPF to peer with R4.

The routes received by 7200 from R1

192.168.31.0 - as path 3

192.168.41.0 - as path 3 20 <-- this is the one we are setting tag of 200 on.

router ospf 10

log-adjacency-changes

redistribute bgp 10 subnets route-map MPL

network 172.16.22.0 0.0.0.255 area 0

!

router bgp 10

no synchronization

bgp log-neighbor-changes

network 10.9.1.0 mask 255.255.255.240

network 172.16.22.0 mask 255.255.255.0

neighbor 192.168.5.1 remote-as 3

no auto-summary

!

ip as-path access-list 2 permit 3 20

!

route-map MPL permit 10

match as-path 2

set tag 200

!

route-map MPL permit 20

Output from R4

R4#sh ip ro 192.168.31.0

Routing entry for 192.168.31.0/24

Known via "ospf 1", distance 110, metric 1

Tag 3, type extern 2, forward metric 1

Last update from 172.16.22.1 on FastEthernet0/1, 00:12:39 ago

Routing Descriptor Blocks:

* 172.16.22.1, from 192.168.6.2, 00:12:39 ago, via FastEthernet0/1

Route metric is 1, traffic share count is 1

Route tag 3

R4#sh ip ro 192.168.41.0

Routing entry for 192.168.41.0/24

Known via "ospf 1", distance 110, metric 1

Tag 200, type extern 2, forward metric 1

Last update from 172.16.22.1 on FastEthernet0/1, 00:13:04 ago

Routing Descriptor Blocks:

* 172.16.22.1, from 192.168.6.2, 00:13:04 ago, via FastEthernet0/1

Route metric is 1, traffic share count is 1

Route tag 200

HTH

Jon

rmv72 Tue, 01/29/2008 - 00:24

And now i can have routes at R4 with different route tags. But how to use it is later? I mean how to convert Route tag to metric which can influence which route to use )?

Correct Answer
Jon Marshall Tue, 01/29/2008 - 00:37

Ah well, you never said you wanted to do anything with them :)

If you want to set metrics you are better doing it when you redistribute - on the 7200 in our example. So you still use the as-paths to identify the relevant routes but then just set the metric you need.

Jon

royalblues Tue, 01/29/2008 - 00:40

you would be better off configuring the metric while redistribution

Make sure the router that is setting the as-path prepend redistributes with a higher metric

Narayan

Jon Marshall Tue, 01/29/2008 - 00:44

Narayan

After messing around in a lab with route-maps, as-path's etc. i came to the same conclusion as you. The fact that you got straight to the point while i went round the houses should tell me something :)

Jon

rmv72 Tue, 01/29/2008 - 00:52

Narayan, i didn't understand your warning.

If i use as-path prepending i don't set metric because (if i correct) during flowing through transit AS MED will be lost?

Or did you mean something else?

royalblues Tue, 01/29/2008 - 01:09

When i meant metric it is the ospf metric and not the BGP MED so that the internal routers chose the correct border router for exit

Narayan

Actions

This Discussion