In case you wondered how to redistribute static routes into dynamic routing protocol you are at the right place. This is normally a basic thing to do, but I will let you know how to do it in different ways on different vendor devices so it might be interesting.
We will go through few examples of normal static to OSPF redistribution and then see how it can be partially done with only part of static routes using route filters. I’ll do it on Cisco and Juniper devices so we can see what’s the difference.
Cisco
In Cisco CLI, redistribute static is fairly simple thing to do:
Router(config)#router ospf 1 Router(config-router)#redistribute static subnets
But you need to know that this simple command will take all static router available on that router and push them to OSPF and redistribute them to all other routers participating in that OSPF process.
If you want to redistribute just some of the static routes, or in our next example only static route towards the network 10.10.10.0/24 you need route map filtering in redistribution command to reference only that one network:
We create an access-list with which we will reference to that network and then use that access-list inside route-map. Route-map will then be referenced in redistribution command:
access-list 11 permit 10.10.10.0 0.0.0.255 route-map REDISTRIBUTE permit 10 match ip address 11 router ospf 1 redistribute static route-map REDISTRIBUTE subnets
IF we need more granular matching on prefix length, we can use prefix-list instead of access-list
ip prefix-list PREFIX permit 10.10.10.0/24 route-map REDISTRIBUTE permit 10 match ip address prefix-list PREFIX router ospf 1 redistribute static route-map REDISTRIBUTE subnets
Juniper
In case of Juniper, we are using ‘set protocols ospf export’ command to redistribute.
In our example, if we want to redistribute all static routes into OSPF we are creating something like this:
set policy-options policy-statement REDISTRIBUTE_ALL_STATIC term 1 from protocol static set policy-options policy-statement REDISTRIBUTE_ALL_STATIC term 1 then accept set protocols ospf export REDISTRIBUTE_ALL_STATIC
If fo example we want to redistribute into OSPF only 10.10.10.0/24 network, then we need to add extra condition into policy-statement which is basically matching the network with prefix-list:
set policy-options policy-statement REDISTRIBUTE_STATIC term 1 from protocol static set policy-options policy-statement REDISTRIBUTE_STATIC term 1 from route-filter 10.10.10.0/24 prefix-length-range /24-/24 set policy-options policy-statement REDISTRIBUTE_STATIC term 1 then accept set protocols ospf export REDISTRIBUTE_STATIC
I follow you on twitter and your blog and I am a fan. Thank you for always sharing. I have a couple corrections to this post. I don’t mean to be harsh in this reply. I only do this because I care. You have a great blog and I want to help make sure the documentation is correct.
Instead you should use:
Also the access-list should use wildcard bits not subnet mask.
The correct access-list would be:
For example if the below was entered the problems are two fold:
! 1) the access-list should be using wildcard bits
! 2) you should be using the “subnets” keyword in the redistribution command
..you should be using the corrected access-list from above as well as changing the redistribute command to include the “subnets” keyword:
! The syntax for your prefix-list is wrong:
If you are trying to match only 10.10.10.0 then the correct prefix-list would be:
with love,
@showipintbri
Hi show interface man 🙂
Thanks! I will update the article to get things right. I was actually doing those things on Juniper at the time and put the Cisco part as a reference. I wrote Cisco part from my head without labbing it first, which, as we can see, is not always the best thing to do..
🙂
thanks again.