Support Support Downloads Knowledge Base Juniper Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

How to inject default route into OSPF using generate route

0

0

Article ID: KB37303 KB Last Updated: 17 Sep 2021Version: 1.0
Summary:

This article demonstrates how to configure a generated route and inject that default route in OSPF from R2 to R3 based on the presence of 172.16.0.0/32 in the BGP routing table in R2. Also, if in case we lose that route we want to flush the default route from our OSPF domain.

Solution:

Topology:

R1 (192.168.12.1) ---- EBGP ---- (192.168.12.2) R2 (192.168.23.1) ---- OSPF ---- (192.168.23.2) R3

In the following policy, we match the BGP route and based on that we inject a default generate route:

set policy-options policy-statement BGP_IMPORT term 1 from protocol bgp
set policy-options policy-statement BGP_IMPORT term 1 from route-filter 172.16.0.0/32 exact
set policy-options policy-statement BGP_IMPORT term 1 then accept
set policy-options policy-statement BGP_IMPORT term 2 then reject

set routing-options generate defaults preference 130
set routing-options generate route 0.0.0.0/0 policy BGP_IMPORT


In following policy we match the default aggregated route that was generated and export into OSPF:

set policy-options policy-statement OSPF_EXPORT term 1 from protocol aggregate
set policy-options policy-statement OSPF_EXPORT term 1 from route-filter 0.0.0.0/0 exact
set policy-options policy-statement OSPF_EXPORT term 1 then accept

set protocols ospf export OSPF_EXPORT

R2_RE> show route receive-protocol bgp 192.168.12.1    
inet.0: 38 destinations, 38 routes (38 active, 0 holddown, 0 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 172.16.0.0/32           192.168.12.1                            1 I
* 172.16.0.1/32           192.168.12.1                            1 I
* 172.16.0.2/32           192.168.12.1                            1 I
* 172.16.0.3/32           192.168.12.1                            1 I
* 172.16.0.4/32           192.168.12.1                            1 I

R2_RE> show route 0/0 exact detail 
inet.0: 38 destinations, 38 routes (38 active, 0 holddown, 0 hidden)
0.0.0.0/0 (1 entry, 1 announced)
        *Aggregate Preference: 130
                Next hop type: Router, Next hop index: 614
                Address: 0xc8d6770
                Next-hop reference count: 16
                Next hop: 192.168.12.1 via ge-0/0/0.0, selected   <-- The default next hop for generate route will be associated with the next hop of primary contributing route
                Session Id: 0x140
                State: <Active Int Ext>
                Local AS:     2 
                Age: 3:03 
                Validation State: unverified 
                Task: Aggregate
                Announcement bits (2): 0-KRT 2-OSPF 
                AS path: I 
                                Flags: Generate Depth: 0        Active
                Contributing Routes (1):
                        172.16.0.0/32 proto BGP  <-- This is primary contributing route which has a next hop of 192.168.12.1 in bgp table

R3_RE> show route 0/0 exact detail       
inet.0: 36 destinations, 36 routes (36 active, 0 holddown, 0 hidden)
0.0.0.0/0 (1 entry, 1 announced)
        *OSPF   Preference: 150
                Next hop type: Router, Next hop index: 618
                Address: 0xc8d5f90
                Next-hop reference count: 18
                Next hop: 192.168.23.1 via ge-0/0/4.0, selected
                Session Id: 0x140
                State: <Active Int Ext>
                Age: 7:33       Metric: 0 
                Validation State: unverified 
                        Tag: 0 
                Task: OSPF
                Announcement bits (1): 0-KRT 
                AS path: I 

Once route is lost, flush out default aggregate route:

R2_RE> show route receive-protocol bgp 192.168.12.1    
inet.0: 37 destinations, 37 routes (36 active, 0 holddown, 1 hidden)
  Prefix                  Nexthop              MED     Lclpref    AS path
* 172.16.0.1/32           192.168.12.1                            1 I
* 172.16.0.2/32           192.168.12.1                            1 I
* 172.16.0.3/32           192.168.12.1                            1 I
* 172.16.0.4/32           192.168.12.1                            1 I

R2_RE> show route 0/0 exact detail 
inet.0: 37 destinations, 37 routes (36 active, 0 holddown, 1 hidden)

R3_RE> show route 0/0 exact detail 
Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search