Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation

Example: Configuring a Conditional OSPF Default Route Policy on Logical Systems

This example shows how to configure a conditional default route on one logical system and inject the default route into OSPF area 0.

Requirements

Before you begin:

Overview

In this example, OSPF area 0 contains three logical systems that are configured on a single physical router. Logical System LS3 has a BGP session with an external peer, for example, an ISP.

The ISP injects a default static route into BGP, which provides the customer network with a default static route to reach external networks. Logical System LS3 exports the default route into OSPF. The route policy on Logical System LS3 is conditional such that if the connection to the external peer goes down, the default route is no longer active in the routing tables of the logical systems in area 0. This policy prevents blackholing of traffic. Blackholing occurs when packets are dropped without notification.

Figure 1 shows the sample network.

Figure 1: OSPF with a Conditional Default Route to an ISP

OSPF with a Conditional
Default Route to an ISP

Configuration

CLI Quick Configuration

To quickly configure this example, copy the following commands, paste them into a text file, remove any line breaks, change any details necessary to match your network configuration, and then copy and paste the commands into the CLI at the [edit] hierarchy level.

Device LS1

set logical-systems LS1 interfaces lt-1/2/0 unit 0 description LS1->LS3set logical-systems LS1 interfaces lt-1/2/0 unit 0 encapsulation ethernetset logical-systems LS1 interfaces lt-1/2/0 unit 0 peer-unit 5set logical-systems LS1 interfaces lt-1/2/0 unit 0 family inet address 10.0.1.2/30set logical-systems LS1 interfaces lt-1/2/0 unit 2 description LS1->LS2set logical-systems LS1 interfaces lt-1/2/0 unit 2 encapsulation ethernetset logical-systems LS1 interfaces lt-1/2/0 unit 2 peer-unit 1set logical-systems LS1 interfaces lt-1/2/0 unit 2 family inet address 10.0.0.1/30set logical-systems LS1 protocols ospf area 0.0.0.0 interface lt-1/2/0.0set logical-systems LS1 protocols ospf area 0.0.0.0 interface lt-1/2/0.2

Device LS2

set logical-systems LS2 interfaces lt-1/2/0 unit 1 description LS2->LS1set logical-systems LS2 interfaces lt-1/2/0 unit 1 encapsulation ethernetset logical-systems LS2 interfaces lt-1/2/0 unit 1 peer-unit 2set logical-systems LS2 interfaces lt-1/2/0 unit 1 family inet address 10.0.0.2/30set logical-systems LS2 interfaces lt-1/2/0 unit 4 description LS2->LS3set logical-systems LS2 interfaces lt-1/2/0 unit 4 encapsulation ethernetset logical-systems LS2 interfaces lt-1/2/0 unit 4 peer-unit 3set logical-systems LS2 interfaces lt-1/2/0 unit 4 family inet address 10.0.2.2/30set logical-systems LS2 protocols ospf area 0.0.0.0 interface lt-1/2/0.1set logical-systems LS2 protocols ospf area 0.0.0.0 interface lt-1/2/0.4

Device LS3

set logical-systems LS3 interfaces lt-1/2/0 unit 3 description LS3->LS2set logical-systems LS3 interfaces lt-1/2/0 unit 3 encapsulation ethernetset logical-systems LS3 interfaces lt-1/2/0 unit 3 peer-unit 4set logical-systems LS3 interfaces lt-1/2/0 unit 3 family inet address 10.0.2.1/30set logical-systems LS3 interfaces lt-1/2/0 unit 5 description LS3->LS1set logical-systems LS3 interfaces lt-1/2/0 unit 5 encapsulation ethernetset logical-systems LS3 interfaces lt-1/2/0 unit 5 peer-unit 0set logical-systems LS3 interfaces lt-1/2/0 unit 5 family inet address 10.0.1.1/30set logical-systems LS3 interfaces so-0/0/2 unit 0 description LS3->ISPset logical-systems LS3 interfaces so-0/0/2 unit 0 family inet address 10.0.45.2/30set logical-systems LS3 protocols bgp group ext type externalset logical-systems LS3 protocols bgp group ext peer-as 65000set logical-systems LS3 protocols bgp group ext neighbor 10.0.45.1set logical-systems LS3 protocols ospf export gendefaultset logical-systems LS3 protocols ospf area 0.0.0.0 interface lt-1/2/0.5set logical-systems LS3 protocols ospf area 0.0.0.0 interface lt-1/2/0.3set logical-systems LS3 policy-options policy-statement gendefault term upstreamroutes from protocol bgpset logical-systems LS3 policy-options policy-statement gendefault term upstreamroutes from as-path upstreamset logical-systems LS3 policy-options policy-statement gendefault term upstreamroutes from route-filter 0.0.0.0/0 upto /16set logical-systems LS3 policy-options policy-statement gendefault term upstreamroutes then next-hop 10.0.45.1set logical-systems LS3 policy-options policy-statement gendefault term upstreamroutes then acceptset logical-systems LS3 policy-options policy-statement gendefault term end then rejectset logical-systems LS3 policy-options as-path upstream "^65000 "set logical-systems LS3 routing-options generate route 0.0.0.0/0 policy gendefaultset logical-systems LS3 routing-options autonomous-system 65001

Device ISP

set interfaces so-0/0/2 unit 0 family inet address 10.0.45.1/30set protocols bgp group ext type externalset protocols bgp group ext export advertise-defaultset protocols bgp group ext peer-as 65001set protocols bgp group ext neighbor 10.0.45.2set policy-options policy-statement advertise-default term 1 from route-filter 0.0.0.0/0 exactset policy-options policy-statement advertise-default term 1 then acceptset routing-options static route 0.0.0.0/0 discardset routing-options autonomous-system 65000

Step-by-Step Procedure

The following example requires you to navigate various levels in the configuration hierarchy. For information about navigating the CLI, see Using the CLI Editor in Configuration Mode in the CLI User Guide.

To configure a conditional default route:

  1. Configure the interfaces.
    [edit logical-systems LS3 interfaces]user@R3# set lt-1/2/0 unit 3 description LS3->LS2user@R3# set lt-1/2/0 unit 3 encapsulation ethernetuser@R3# set lt-1/2/0 unit 3 peer-unit 4user@R3# set lt-1/2/0 unit 3 family inet address 10.0.2.1/30user@R3# set lt-1/2/0 unit 5 description LS3->LS1user@R3# set lt-1/2/0 unit 5 encapsulation ethernetuser@R3# set lt-1/2/0 unit 5 peer-unit 0user@R3# set lt-1/2/0 unit 5 family inet address 10.0.1.1/30user@R3# set so-0/0/2 unit 0 description LS3->ISPuser@R3# set so-0/0/2 unit 0 encapsulation ethernetuser@R3# set so-0/0/2 unit 0 peer-unit 7user@R3# set so-0/0/2 unit 0 family inet address 10.0.45.2/30
  2. Configure the autonomous system (AS) number.

    [edit logical-systems LS3 routing-options]user@R3# set autonomous-system 65001
  3. Configure the BGP session with the ISP device.
    [edit logical-systems LS3 protocols bgp group ext]user@R3# set type externaluser@R3# set peer-as 65000user@R3# set neighbor 10.0.45.1
  4. Configure OSPF.

    [edit logical-systems LS3 protocols ospf area 0.0.0.0]user@R3# set interface lt-1/2/0.5user@R3# set interface lt-1/2/0.3
  5. Configure the routing policy.

    [edit logical-systems LS3 policy-options policy-statement gendefault]user@R3# set term upstreamroutes from protocol bgpuser@R3# set term upstreamroutes from as-path upstreamuser@R3# set term upstreamroutes from route-filter 0.0.0.0/0 upto /16user@R3# set term upstreamroutes then next-hop 10.0.45.1user@R3# set term upstreamroutes then accept
    user@R3# set term end then reject
    [edit logical-systems LS3 policy-options]user@R3# set as-path upstream "^65000 "
  6. Configure the generated route.

    [edit logical-systems LS3 routing-options]user@R3# set generate route 0.0.0.0/0 policy gendefault
  7. Apply the export policy to OSPF.

    [edit logical-systems LS3 protocols ospf]user@R3# set export gendefault
  8. If you are done configuring the device, commit the configuration.

    [edit]user@R3# commit

Results

Confirm your configuration by issuing the show logical-systems LS3 command.

show logical-systems LS3interfaces {lt-1/2/0 {unit 3 {description LS3->LS2;encapsulation ethernet;peer-unit 4;family inet {address 10.0.2.1/30;}}unit 5 {description LS3->LS1;encapsulation ethernet;peer-unit 0;family inet {address 10.0.1.1/30;}}unit 6 {description LS3->ISP;encapsulation ethernet;peer-unit 7;family inet {address 10.0.45.2/30;}}}}protocols {bgp {group ext {type external;peer-as 65000;neighbor 10.0.45.1;}}ospf {export gendefault;area 0.0.0.0 {interface lt-1/2/0.5;interface lt-1/2/0.3;}}}policy-options {policy-statement gendefault {term upstreamroutes {from {protocol bgp;as-path upstream;route-filter 0.0.0.0/0 upto /16;}then {next-hop 10.0.45.1;accept;}}term end {then reject;}}as-path upstream "^65000 ";}routing-options {generate {route 0.0.0.0/0 policy gendefault;}autonomous-system 65001;}

Verification

Confirm that the configuration is working properly.

Verifying that the Route to the ISP Is Working

Purpose

Make sure connectivity is established between Logical System LS3 and the ISP’s router.

Action

user@host>set cli logical-system LS3
Logical system: LS3

user@host:LS3>ping 10.0.45.1
PING 10.0.45.1 (10.0.45.1): 56 data bytes
64 bytes from 10.0.45.1: icmp_seq=0 ttl=64 time=1.185 ms
64 bytes from 10.0.45.1: icmp_seq=1 ttl=64 time=1.199 ms
64 bytes from 10.0.45.1: icmp_seq=2 ttl=64 time=1.186 ms

Meaning

The ping command confirms reachability.

Verifying That the Static Route Is Redistributed

Purpose

Make sure that the BGP policy is redistributing the static route into Logical System LS3’s routing table. Also make sure that the OSPF policy is redistributing the static route into the routing tables of Logical System LS1 and Logical System LS2.

Action

user@host> show route logical-system LS3 protocol bgp
inet.0: 9 destinations, 10 routes (9 active, 0 holddown, 1 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[BGP/170] 00:00:25, localpref 100
                      AS path: 65000 I
                    > to 10.0.45.1 via so-0/0/2.0
user@host> show route logical-system LS1 protocol ospf
inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[OSPF/150] 00:03:58, metric 0, tag 0
                    > to 10.0.1.1 via lt-1/2/0.0
10.0.2.0/30        *[OSPF/10] 03:37:45, metric 2
                      to 10.0.1.1 via lt-1/2/0.0
                    > to 10.0.0.2 via lt-1/2/0.2
224.0.0.5/32       *[OSPF/10] 03:38:41, metric 1
                      MultiRecv
user@host> show route logical-system LS2 protocol ospf
inet.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[OSPF/150] 00:04:04, metric 0, tag 0
                    > to 10.0.2.1 via lt-1/2/0.4
10.0.1.0/30        *[OSPF/10] 03:37:46, metric 2
                      to 10.0.0.1 via lt-1/2/0.1
                    > to 10.0.2.1 via lt-1/2/0.4
224.0.0.5/32       *[OSPF/10] 03:38:47, metric 1
                      MultiRecv

Meaning

The routing tables contain the default 0.0.0.0/0 route. If Logical System LS1 and Logical System LS2 receive packets destined for networks not specified in their routing tables, those packets will be sent to Logical System LS3 for further processing. If Logical System LS3 receives packets destined for networks not specified in its routing table, those packets will be sent to the ISP for further processing.

Testing the Policy Condition

Purpose

Deactivate the interface to make sure that the route is removed from the routing tables if the external network becomes unreachable.

Action

user@host> deactivate logical-systems LS3 interfaces so-0/0/2 unit 0 family inet address 10.0.45.2/30

user@host> commit
user@host> show route logical-system LS1 protocol ospf
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.2.0/30        *[OSPF/10] 03:41:48, metric 2
                      to 10.0.1.1 via lt-1/2/0.0
                    > to 10.0.0.2 via lt-1/2/0.2
224.0.0.5/32       *[OSPF/10] 03:42:44, metric 1
                      MultiRecv

user@host> show route logical-system LS2 protocol ospf
inet.0: 6 destinations, 6 routes (6 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.0.1.0/30        *[OSPF/10] 03:42:10, metric 2
                      to 10.0.0.1 via lt-1/2/0.1
                    > to 10.0.2.1 via lt-1/2/0.4
224.0.0.5/32       *[OSPF/10] 03:43:11, metric 1
                      MultiRecv

Meaning

The routing tables on Logical System LS1 and Logical System LS2 do not contain the default 0.0.0.0/0. This verifies that the default route is no longer present in the OSPF domain. To reactivate the so-0/0/2.0 interface, issue the activate logical-systems LS3 interfaces so-0/0/2 unit 0 family inet address 10.0.45.2/30 configuration-mode command.

Published: 2012-12-08