11-23-2023 04:50 AM
Hi,
I am doing a lab and was wondering if there is a way of injecting a default route into OSPF if a route doesn't exist in the routing tables. I know this can be done using object tracking but I wanted to try it with route maps, however, it does not appear to be working. My config is as follows:
ip route 0.0.0.0 0.0.0.0 Null0
!
!
ip access-list standard R1-LO3
permit 3.0.0.0 0.255.255.255
!
!
route-map R2-DEFAULT-ROUTE deny 10
match ip address R1-LO3
!
route-map R2-DEFAULT-ROUTE permit 20
!
!
router ospf 1
default-information originate route-map R2-DEFAULT-ROUTE
Any help will be appreciated.
Sam
11-24-2023 02:08 AM
- Could you try this configuration instead :
ip route 0.0.0.0 0.0.0.0 Null0
!
ip access-list standard R1-LO3
permit 3.0.0.0 0.255.255.255
!
route-map R2-DEFAULT-ROUTE deny 10
!
route-map R2-DEFAULT-ROUTE permit 20
!
router ospf 1
default-information originate route-map R2-DEFAULT-ROUTE
M.
11-24-2023 02:19 AM - edited 11-24-2023 02:20 AM
Hello
One way you can do is use the "always" keyword, most applicable when you have a stub network downstrean and the only way external is via the rtr you are advertsing the default from.
router ospf 1
default-information originate route always
11-24-2023 02:20 AM - edited 11-24-2023 11:55 AM
If the router is abr or internal then you can use keyword always
If it asbr you need defualt route in RIB before ospf can advertise it
Now route-map with default originate I think it use to set tag (set metric and type can direct config no need route-map for set it)
AND
AND
For case 1 using always you can use route map to conditional advertise defualt if OTHER prefix appeat in RIB'
So your lab
Remove defualt route to null0
Add new any static route
Add always to defualt command
Make route-map checking the static route of it appear in rib or not
If you use route-map to track with default information it useless no meaning and the router ignore it
11-24-2023 02:42 AM - edited 11-24-2023 02:44 AM
Hello @Sam-CCNP ,
the use of a route-map in default-originate is to check some conditions that should be met to inject the default route in OSPF domain.
Your route-map logic contains a deny statement as first block that is matched if a route in 3.0.0.0/8 is present in the routing table. As a result of this no default route is injected in the routing table.
If you shut down the loopback with that IP address and no other route matches the first route-map block the second route-map block/clause with permit action is used and the default route is generated.
Try to test shutting down that loopback and see what happens.
Hope to help
Giuseppe
11-24-2023 05:11 AM
Hi Giuseppe,
Thank you for responding, I did indeed shut the Loopback 3 R1 down, however, the default route is still not advertised - which is why it doesn't seem to work:
! R2's routing table:
R2#sh ip route 3.0.0.0 255.0.0.0
% Network not in table
! No type-5 default route is being advertised
R2#sh ip ospf database external
OSPF Router with ID (23.1.1.2) (Process ID 1)
R2#
! Also confirmed on R3, which is R2's OSPF neighbor:
R3#sh ip route
Gateway of last resort is not set
23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 23.1.1.0/24 is directly connected, GigabitEthernet0/2
L 23.1.1.3/32 is directly connected, GigabitEthernet0/2
So, to test the opposite - i.e. the default route is only injected if 3.0.0.0 is present - I changed route-map R2-DEFAULT-ROUTE deny 10 to route-map R2-DEFAULT-ROUTE permit 10
And it worked. The default route was only injected into the OSPF area when the 3.0.0.0/8 was present in the routing tables.
It seems to me that checking for missing routes using route-maps and access-lists as a condition for advertising a default route doesn't work. I know there are other ways to achieve this, but I wanted to try this way.
11-24-2023 08:23 AM
Hello @Sam-CCNP ,
to be honest I had always used a positive logic with permit statements in route-maps used with default-originate I see when moving to a positive logic it works as expected
>> The default route was only injected into the OSPF area when the 3.0.0.0/8 was present in the routing tables.
Thanks for your feedback
Best Regards
Giuseppe
11-24-2023 03:08 AM
Hello Sam-CCNP,
can you try with prefix-list...instead of ACL...might helpful....?
ip route 0.0.0.0 0.0.0.0 Null0
!
!
ip prefix-list list-1 permit 3.0.0.0/8
!
!
route-map R2-DEFAULT-ROUTE deny 10
match ip address prefix-list list-1
!
route-map R2-DEFAULT-ROUTE permit 20
!
!
router ospf 1
default-information originate route-map R2-DEFAULT-ROUTE
check...will it make any difference...
Best regards
******* If This Helps, Please Rate *******
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide