Friday, May 21, 2021

Cisco Smart Licensing in ISR 4000

Smart Licensing is enabled by default starting on IOS-XE 16.9.1 and above on Cisco Catalyst 3650/3850 and 9000 series switches and 16.10.1 and above on Cisco ASR1K, ISR1K and ISR4K series routers.

4321#show version

Cisco IOS XE Software, Version 16.12.04

Cisco IOS Software [Gibraltar], ISR Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.12.4, RELEASE SOFTWARE (fc5)

Technical Support: http://www.cisco.com/techsupport

Copyright (c) 1986-2020 by Cisco Systems, Inc.

Compiled Thu 09-Jul-20 21:44 by mcpre

 

 

Cisco IOS-XE software, Copyright (c) 2005-2020 by cisco Systems, Inc.

All rights reserved.  Certain components of Cisco IOS-XE software are

licensed under the GNU General Public License ("GPL") Version 2.0.  The

software code licensed under GPL Version 2.0 is free software that comes

with ABSOLUTELY NO WARRANTY.  You can redistribute and/or modify such

GPL code under the terms of GPL Version 2.0.  For more details, see the

documentation or "License Notice" file accompanying the IOS-XE software,

or the applicable URL provided on the flyer accompanying the IOS-XE

software.

 

 

ROM: 16.12(2r)

 

4321 uptime is 14 hours, 1 minute

Uptime for this control processor is 14 hours, 4 minutes

System returned to ROM by Reload Command at 09:29:30 UTC Thu Mar 18 2021

System restarted at 09:34:02 UTC Thu Mar 18 2021

System image file is "bootflash:isr4300-universalk9.16.12.04.SPA.bin"

Last reload reason: Reload Command

 

 

This product contains cryptographic features and is subject to United

States and local country laws governing import, export, transfer and

use. Delivery of Cisco cryptographic products does not imply

third-party authority to import, export, distribute or use encryption.

Importers, exporters, distributors and users are responsible for

compliance with U.S. and local country laws. By using this product you

agree to comply with applicable laws and regulations. If you are unable

to comply with U.S. and local laws, return this product immediately.

 

A summary of U.S. laws governing Cisco cryptographic products may be found at:

http://www.cisco.com/wwl/export/crypto/tool/stqrg.html

 

If you require further assistance please contact us by sending email to

export@cisco.com.

 

 

Suite License Information for Module:'esg'

 

--------------------------------------------------------------------------------

Suite                 Suite Current         Type           Suite Next reboot    

--------------------------------------------------------------------------------

FoundationSuiteK9     None                  Smart License  None                 

securityk9

appxk9   

AdvUCSuiteK9          None                  Smart License  None                 

uck9

cme-srst

cube

 

 

Technology Package License Information:

 

-----------------------------------------------------------------

Technology    Technology-package           Technology-package

              Current       Type           Next reboot 

------------------------------------------------------------------

appxk9           None             Smart License    None

uck9             uck9             Smart License    uck9

securityk9       None             Smart License    None

ipbase           ipbasek9         Smart License    ipbasek9

 

The current throughput level is unthrottled

 

 

Smart Licensing Status: UNREGISTERED/EVAL MODE

 

cisco ISR4321/K9 (1RU) processor with 1694893K/3071K bytes of memory.

Processor board ID FLM24481234

1 Virtual Ethernet interface

10 Gigabit Ethernet interfaces

24 Serial interfaces

2 Channelized T1/PRI ports

32768K bytes of non-volatile configuration memory.

4194304K bytes of physical memory.

3125247K bytes of flash memory at bootflash:.

0K bytes of WebUI ODM Files at webui:.

 

Configuration register is 0x2102


 

Smart Call-Home (SCH) is configured by default per above IOS-XE releases.

 

4321#show run | section call-home

service call-home

call-home

 ! If contact email address in call-home is configured as sch-smart-licensing@cisco.com

 ! the email address configured in Cisco Smart License Portal will be used as contact email address to send SCH notifications.

 contact-email-addr sch-smart-licensing@cisco.com

 profile "CiscoTAC-1"

  active

  destination transport-method http

  no destination transport-method email

 

 

To check the Smart License status, issue either a show license status or show license summary command.

 

Notice the device Status is UNREGISTERED and License Count Status is EVAL MODE.

 

4321#show license status

Smart Licensing is ENABLED

 

Utility:

  Status: DISABLED

 

Data Privacy:

  Sending Hostname: yes

    Callhome hostname privacy: DISABLED

    Smart Licensing hostname privacy: DISABLED

  Version privacy: DISABLED

 

Transport:

  Type: Callhome

 

Registration:

  Status: UNREGISTERED - REGISTRATION PENDING

  Export-Controlled Functionality: NOT ALLOWED

  Initial Registration: First Attempt Pending

 

License Authorization:

  Status: EVAL MODE

  Evaluation Period Remaining: 86 days, 8 hours, 10 minutes, 38 seconds

 

License Conversion:

  Automatic Conversion Enabled: False

  Status: Not started

 

Export Authorization Key:

  Features Authorized:

    <none>

 

 

4321#show license summary

Smart Licensing is ENABLED

 

Registration:

  Status: UNREGISTERED - REGISTRATION PENDING

  Export-Controlled Functionality: NOT ALLOWED

 

License Authorization:

  Status: EVAL MODE

  Evaluation Period Remaining: 86 days, 8 hours, 9 minutes, 48 seconds

 

License Usage:

  License                 Entitlement tag               Count Status

  -----------------------------------------------------------------------------

                          (ISR_4321_UnifiedCommun...)       1 EVAL MODE

                          (ISR_4321_BOOST)                  1 EVAL MODE

 

 

You need to create a Virtual Account on the Cisco Smart Software Manager (CSSM) portal, which is under Administration > click Manage Smart Account.

 

To manage Smart Licenses in the CSSM portal go under License > click Smart Software Licensing.

 

First generate a registration token in CSSM under Inventory.

Select the Virtual Account > click New Token. 


Type a Description (i.e. router hostname) > leave the default Expire After: 30 Days > leave blank for the Max. Number of Users > leave the Allow export-controlled functionality selected > click Create Token.


Notice the top most token that was generated. It has a 30 days (1 month) expiration date/use.

Click the blue arrow icon beside the newly generated token > hit Ctrl+C to copy to clipboard.


Before applying the new token, ensure the router can reach the SCH/CSSM cloud over the Internet.

 

4321#ping tools.cisco.com

% Unrecognized host or address, or protocol not running.

 

4321#ping 8.8.8.8

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 ms

 

 

Configure DNS and domain lookup on the router . You can alternatively use the ip host <HOSTNAME> <IP ADDRESS> command to manually map Call Home to a static public IP address.

 

4321(config)#ip name-server 8.8.8.8

4321(config)#ip domain lookup 

4321(config)#end

 

4321#ping tools.cisco.com

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 72.163.4.38, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 218/218/219 ms

 


Next, issue a license smart register idtoken <TOKEN> privilege mode command.

 

4321#license ?

  smart  Smart licensing

 

4321#license smart ?

  clear       Clear

  conversion  Start or stop a license conversion

  deregister  deregister this device

  export      Get or return an export authorization key

  factory     Execute Smart Licensing Factory commands

  register    register token id

  renew       Smart License renew

  send        license smart send

 

4321#license smart register ?

  idtoken  id token

 

4321#license smart register idtoken ? 

  WORD  reg id

 

4321#license smart register idtoken ZTVmZDQ3MGItZTY4My00NDgzLWEwZmItZTVkZDYxMzVlODQ0LTE2MTg3MDUx%0AODU4Mzl8aXJLOXNYb0JORmtrZHJsY3ZRbHZqbzd3RC9NbUQxWGRDY2M1TmMw%0AejFsTT0%12345

Registration process is in progress. Use the 'show license status' command to check the progress and result

 

Mar 19 00:43:51.297 UTC: %CRYPTO_ENGINE-5-KEY_ADDITION: A key named SLA-KeyPair has been generated or imported by crypto-engine

Mar 19 00:43:51.375 UTC: %PKI-4-NOCONFIGAUTOSAVE: Configuration was modified.  Issue "write memory" to save new IOS PKI configurations



You can check the Smart License status using either the show license status or show license summary command. Notice the Status changed to UNREGISTERED - REGISTRATION PENDING.


4321#show license status

Smart Licensing is ENABLED

 

Utility:

  Status: DISABLED

 

Data Privacy:

  Sending Hostname: yes

    Callhome hostname privacy: DISABLED

    Smart Licensing hostname privacy: DISABLED

  Version privacy: DISABLED

 

Transport:

  Type: Callhome

 

Registration:

  Status: UNREGISTERED - REGISTRATION PENDING

  Export-Controlled Functionality: NOT ALLOWED

  Initial Registration: First Attempt Pending

 

License Authorization:

  Status: EVAL MODE

  Evaluation Period Remaining: 86 days, 8 hours, 10 minutes, 38 seconds

 

License Conversion:

  Automatic Conversion Enabled: False

  Status: Not started

 

Export Authorization Key:

  Features Authorized:

    <none>

 

 

4321#show license summary

Smart Licensing is ENABLED

 

Registration:

  Status: UNREGISTERED - REGISTRATION PENDING

  Export-Controlled Functionality: NOT ALLOWED

 

License Authorization:

  Status: EVAL MODE

  Evaluation Period Remaining: 86 days, 8 hours, 9 minutes, 48 seconds

 

License Usage:

  License                 Entitlement tag               Count Status

  -----------------------------------------------------------------------------

                          (ISR_4321_UnifiedCommun...)       1 EVAL MODE

                          (ISR_4321_BOOST)                  1 EVAL MODE

 

 

The Internet connection was initially unstable/intermittent causing the SCH connection to fail.

 

4321#

Mar 19 00:57:45.880 UTC: %CALL_HOME-5-SL_MESSAGE_FAILED: Fail to send out Smart Licensing message to: https://tools.cisco.com/its/service/oddce/services/DDCEService (ERR 220 : HTTP protocol level failure)

Mar 19 00:57:45.880 UTC: %SMART_LIC-3-AGENT_REG_FAILED: Smart Agent for Licensing Registration with the Cisco Smart Software Manager (CSSM) failed: Fail to send out Call Home HTTP message.

Mar 19 00:57:45.881 UTC: %SMART_LIC-3-COMM_FAILED: Communications failure with the Cisco Smart Software Manager (CSSM) : Fail to send out Call Home HTTP message. 


Verify again the Smart License status. Notice the Status changed to REGISTERING - REGISTRATION IN PROGRESS. Also notice the next registration attempt is few minutes away from the router clock (my router used NTP)

4321#show license status

Smart Licensing is ENABLED

 

Utility:

  Status: DISABLED

 

Data Privacy:

  Sending Hostname: yes

    Callhome hostname privacy: DISABLED

    Smart Licensing hostname privacy: DISABLED

  Version privacy: DISABLED

 

Transport:

  Type: Callhome

 

Registration:

  Status: REGISTERING - REGISTRATION IN PROGRESS

  Export-Controlled Functionality: NOT ALLOWED

  Initial Registration: FAILED on Mar 19 00:57:45 2021 UTC

    Failure reason: Fail to send out Call Home HTTP message.

  Next Registration Attempt: Mar 19 01:15:54 2021 UTC

 

License Authorization:

  Status: EVAL MODE

  Evaluation Period Remaining: 86 days, 7 hours, 52 minutes, 58 seconds

 

License Conversion:

  Automatic Conversion Enabled: False

  Status: Not started

 

Export Authorization Key:

 

  Features Authorized:

    <none>

 

 

4321#show clock

01:04:53.188 UTC Fri Mar 19 2021

 

You can force update the SCH/device registration using the license smart register idtoken <TOKEN> force command

4321# license smart register idtoken ZTVmZDQ3MGItZTY4My00NDgzLWEwZmItZTVkZDYxMzVlODQ0LTE2MTg3MDUx%0AODU4Mzl8aXJLOXNYb0JORmtrZHJsY3ZRbHZqbzd3RC9NbUQxWGRDY2M1TmMw%0AejFsTT0%12345 ?    

  force  Forcefully register

  <cr>   <cr>

 

4321#license smart register idtoken ItZTY4My00NDgzLWEwZmItZTVkZDYxMzVlODQ0LTE2MTg3MDUx%0AODU4Mzl8aXJLOXNYb0JORmtrZHJsY3ZRbHZqbzd3RC9NbUQxWGRDY2M1TmMw%0AejFsTT0%12345 force        

Registration process is in progress. Use the 'show license status' command to check the progress and result

 

4321#

Mar 19 01:31:22.261 UTC: %CRYPTO_ENGINE-5-KEY_DELETED: A key named SLA-KeyPair has been removed from key storage

Mar 19 01:31:24.012 UTC: %CRYPTO_ENGINE-5-KEY_ADDITION: A key named SLA-KeyPair has been generated or imported by crypto-engine

Mar 19 01:31:24.088 UTC: %PKI-4-NOCONFIGAUTOSAVE: Configuration was modified.  Issue "write memory" to save new IOS PKI configuration

Mar 19 01:31:37.371 UTC: %CALL_HOME-6-SCH_REGISTRATION_IN_PROGRESS: SCH device registration is in progress. Call-home will poll SCH server for registration result. You can also check SCH registration status with "call-home request registration-info" under EXEC mode.

Mar 19 01:31:37.373 UTC: %SMART_LIC-5-COMM_RESTORED: Communications with the Cisco Smart Software Manager (CSSM) restored

Mar 19 01:31:37.567 UTC: %SMART_LIC-6-EXPORT_CONTROLLED: Usage of export controlled features is allowed

Mar 19 01:31:37.568 UTC: %SMART_LIC-6-AGENT_REG_SUCCESS: Smart Agent for Licensing Registration successful. udi PID:ISR4321/K9,SN:FLM24471234

Mar 19 01:31:46.142 UTC: %SMART_LIC-5-IN_COMPLIANCE: All entitlements and licenses in use on this device are authorized

Mar 19 01:31:46.146 UTC: %SMART_LIC-5-END_POINT_RESET: End Point list reset

Mar 19 01:31:46.148 UTC: %SMART_LIC-6-AUTH_RENEW_SUCCESS: Authorization renewal successful. State=authorized for udi PID:ISR4321/K9,SN:FLM24471234


 

Notice the registration status changed to SUCCEEDED and the Count Status changed to AUTHORIZED.


4321#show license status

Smart Licensing is ENABLED

 

Utility:

  Status: DISABLED

 

Data Privacy:

  Sending Hostname: yes

    Callhome hostname privacy: DISABLED

    Smart Licensing hostname privacy: DISABLED

  Version privacy: DISABLED

 

Transport:

  Type: Callhome

 

Registration:

  Status: REGISTERED

  Smart Account: MY_SMART_ACCOUNT

  Virtual Account: MY_VIRTUAL_ACCOUNT

  Export-Controlled Functionality: ALLOWED

  Initial Registration: SUCCEEDED on Mar 19 01:31:37 2021 UTC

  Last Renewal Attempt: None

  Next Renewal Attempt: Sep 15 01:31:36 2021 UTC

  Registration Expires: Mar 19 01:26:31 2022 UTC

 

License Authorization:

  Status: AUTHORIZED on Mar 19 01:31:46 2021 UTC

  Last Communication Attempt: SUCCEEDED on Mar 19 01:31:46 2021 UTC

  Next Communication Attempt: Apr 18 01:31:45 2021 UTC

  Communication Deadline: Jun 17 01:26:43 2021 UTC

 

License Conversion:

  Automatic Conversion Enabled: False

  Status: Not started

 

Export Authorization Key:

  Features Authorized:

    <none>

 

 

4321#show license summary

Smart Licensing is ENABLED

 

Registration:

  Status: REGISTERED

  Smart Account: MY_SMART_ACCOUNT

  Virtual Account: MY_VIRTUAL_ACCOUNT

  Export-Controlled Functionality: ALLOWED

  Last Renewal Attempt: None

  Next Renewal Attempt: Sep 15 01:31:37 2021 UTC

 

License Authorization:

  Status: AUTHORIZED

  Last Communication Attempt: SUCCEEDED

  Next Communication Attempt: Apr 18 01:31:45 2021 UTC

 

License Usage:

  License                 Entitlement tag               Count Status

  -----------------------------------------------------------------------------

  ISR_4321_UnifiedComm... (ISR_4321_UnifiedCommun...)       1 AUTHORIZED

  Boost Performance fo... (ISR_4321_BOOST)                  1 AUTHORIZED

 

To check the device registration status in CSSM, select the Virtual Account > go to Product Instances tab > check the Name of the device > check under Last Contact (2021-Mar-19 01:31:44).

Select the Name (a hyperlink) > under Overview tab > check the Registration Date and Last Contact.

Go to Licenses tab > check under License: Boost Performance for ISR4321 and ISR_4321_UnifiedCommunication > notice the number under Purchased and In use.

I registered two ISR 4321 routers so the count under Purchased and In Use were both 2.


 

To view call-home config and status, issue a show call-home profile all command. Notice the router periodically contacts SCH every 15 days so it's important for the router to have a stable Internet.

 

4321#show call-home ?

  alert-group           Show available alert group

  detail                Show call-home configuration in detail

  diagnostic-signature  Show diagnostic-signature

  events                Show active events

  mail-server           Show call-home mail server related information

  profile               Show existing profiles

  smart-licensing       Show Smart License

  statistics            Show call-home statistics

  version               Show call-home version

  |                     Output modifiers

  <cr>                  <cr>

 

4321#show call-home profile ?

  WORD  Profile name

  all   Show all profiles

 

4321#show call-home profile all

 

Profile Name: CiscoTAC-1

    Profile status: ACTIVE

    Profile mode: Full Reporting

    Reporting Data: Smart Call Home, Smart Licensing

    Preferred Message Format: xml

    Message Size Limit: 3145728 Bytes

    Transport Method: http

    HTTP  address(es): https://tools.cisco.com/its/service/oddce/services/DDCEService

    Other address(es): default

 

    Periodic configuration info message is scheduled every 15 day of the month at 15:41

 

    Periodic inventory info message is scheduled every 15 day of the month at 15:26

 

    Alert-group               Severity

    ------------------------  ------------

    crash                     debug      

    environment               minor      

    inventory                 normal     

 

    Syslog-Pattern            Severity

    ------------------------  ------------

    .*                        major      

 

 

The log message below is a Cisco bug and it was mentioned to simply ignore it since there's no impact.

 

Mar 19 01:33:17.938 UTC: %CALL_HOME-6-UPDATE_SCH_REGISTRATION_STATUS: Device Registration details are not Available

 

 

Don't forget to save config.

 

4321#write memory

Building configuration...

 

[OK]


Sunday, May 2, 2021

Juniper Networks Routing Policy

Routing policy (Class Map and Policy Map in Cisco) allows you to control the flow of routing information to and from the routing table (RT). It can be used to choose which routes to accept or reject from neighbors running dynamic routing protocols. It can control the flow of routing information into the forwarding table (FT).

 

The Junos OS applies import policies before pacing routes in the routing table while export policies are applied as it exports routes from the routing table (RT) to dynamic routing protocols or to the forwarding table. Only active routes are exported from the routing table.

 

jadmin@JR-1> configure

Entering configuration mode

Users currently editing the configuration:

  jadmin terminal p2 (pid 4022) on since 2020-10-21 01:14:03 SGT, idle 02:46:07

      [edit routing-options]

The configuration has been changed but not committed

 

[edit]

jadmin@JR-1# edit policy-options

 

[edit policy-options]

jadmin@JR-1# set policy-statement ?

Possible completions:

  <policy_name>        Name to identify a policy filter

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  dynamic-db           Object may exist in dynamic database

> from                 Conditions to match the source of a route

> term                 Policy term

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy term ?

Possible completions:

  <term_name>

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy term match-rip-routes ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> from                 Conditions to match the source of a route

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy term match-rip-routes from ?

Possible completions:

  aggregate-contributor  Match more specifics of an aggregate

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  area                 OSPF area identifier

+ as-path              Name of AS path regular expression (BGP only)

+ as-path-group        Name of AS path group (BGP only)

  color                Color (preference) value

  color2               Color (preference) value 2

+ community            BGP community

> community-count      Number of BGP communities

+ condition            Condition to match on

> external             External route

  family

  instance             Routing protocol instance

+ interface            Interface name or address

  level                IS-IS level

  local-preference     Local preference associated with a route

  metric               Metric value

  metric2              Metric value 2

  metric3              Metric value 3

  metric4              Metric value 4

> multicast-scope      Multicast scope to match

+ neighbor             Neighboring router

+ next-hop             Next-hop router

  next-hop-type        Next-hop type

  origin               BGP origin attribute

+ policy               Name of policy to evaluate

  preference           Preference value

  preference2          Preference value 2

> prefix-list          List of prefix-lists of routes to match

> prefix-list-filter   List of prefix-list-filters to match

+ protocol             Protocol from which route was learned

  rib                  Routing table

> route-filter         List of routes to match

  route-type           Route type

> source-address-filter  List of source addresses to match

  state                Route state

+ tag                  Tag string

  tag2                 Tag string 2

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy term match-rip-routes from protocol ?

Possible completions:

  [                    Open a set of values

  access               Access server routes

  access-internal      Internal routes to directly connected clients

  aggregate            Aggregate routes

  bgp                  BGP

  direct               Directly connected routes

  dvmrp                Distance Vector Multicast Routing Protocol

  esis                 End System-to-Intermediate System

  isis                 Intermediate System-to-Intermediate System

  l2circuit            Layer 2 circuits

  l2vpn                Layer 2 MPLS virtual private networks

  ldp                  Label Distribution Protocol

  local                Local system addresses

  msdp                 Multicast Source Discovery Protocol

  ospf                 Open Shortest Path First

  ospf2                Open Shortest Path First Version 2

  ospf3                Open Shortest Path First Version 3

  pim                  Protocol Independent Multicast

  rip                  Routing Information Protocol

  ripng                Routing Information Protocol next generation

  rsvp                 Resource Reservation Protocol

  rtarget              Local route target VPN membership

  static               Statically defined addresses

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy term match-rip-routes then ?

Possible completions:

  accept               Accept a route

> aigp-originate       Originate a BGP AIGP attribute

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> as-path-expand       Prepend AS numbers prior to adding local-as (BGP only)

  as-path-prepend      Prepend AS numbers to an AS path (BGP only)

  class                Set class-of-service parameters

> color                Color (preference) value

> color2               Color (preference) value 2

> community            BGP community properties associated with a route

  cos-next-hop-map     Set CoS-based next-hop map in forwarding table

  damping              Define BGP route flap damping parameters

  default-action       Set default policy action

  destination-class    Set destination class in forwarding table

> external             External route

  forwarding-class     Set source or destination class in forwarding table

> install-nexthop      Choose the next hop to be used for forwarding

  label-allocation     Set label allocation mode

> load-balance         Type of load balancing in forwarding table

> local-preference     Local preference associated with a route

> map-to-interface     Set output logical interface

> metric               Metric value

> metric2              Metric value 2

> metric3              Metric value 3

> metric4              Metric value 4

  next                 Skip to next policy or term

> next-hop             Set the address of the next-hop router

  origin               BGP path origin

> preference           Preference value

> preference2          Preference value 2

  priority             Set priority for route installation

  reject               Reject a route

  source-class         Set source class in forwarding table

+ ssm-source           List of Sources for SSM mapping

> tag                  Tag string

> tag2                 Tag string 2

  trace                Log matches to a trace file

[edit policy-options]

jadmin@JR-1# set policy-statement export-rip-policy term match-rip-routes then accept

 

[edit policy-options]

jadmin@JR-1# show

policy-statement export-rip-policy {

    term match-rip-routes {

        from protocol rip;

        then accept;

    }

}

 

[edit policy-options]

 

 

For RIP, you apply import policies at the protocol level and neighbor level hierarchy, whereas you configure export policies only at the group level hierarchy.

 

[edit policy-options]

jadmin@JR-1# top edit protocols rip

 

[edit protocols rip]

jadmin@JR-1# set group ?

Possible completions:

  <group_name>         Group name

[edit protocols rip]

jadmin@JR-1# set group rip-group ?

Possible completions:

  <[Enter]>            Execute this command

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> bfd-liveness-detection  Bidirectional Forwarding Detection options

  demand-circuit       Enable demand circuit on this interface

+ export               Export policy

+ import               Import policy

  max-retrans-time     Maximum time to re-transmit a message in demand-circuit

  metric-out           Default metric of exported routes (1..15)

> neighbor             Neighbor configuration

  preference           Preference of routes learned by this group

  route-timeout        Delay before routes time out (30..360 seconds)

  update-interval      Interval between regular route updates (10..60 seconds)

  |                    Pipe through a command

[edit protocols rip]

jadmin@JR-1# set group rip-group export ?

Possible completions:

  <value>              Export policy

  (                    Open an expression

  [                    Open a set of values

  export-rip-policy

[edit protocols rip]

jadmin@JR-1# set group rip-group export export-rip-routes ?

Possible completions:

  <[Enter]>            Execute this command

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> bfd-liveness-detection  Bidirectional Forwarding Detection options

  demand-circuit       Enable demand circuit on this interface

+ export               Export policy

+ import               Import policy

  max-retrans-time     Maximum time to re-transmit a message in demand-circuit

  metric-out           Default metric of exported routes (1..15)

> neighbor             Neighbor configuration

  preference           Preference of routes learned by this group

  route-timeout        Delay before routes time out (30..360 seconds)

  update-interval      Interval between regular route updates (10..60 seconds)

  |                    Pipe through a command

[edit protocols rip]

jadmin@JR-1# set group rip-group export export-rip-routes neighbor ?

Possible completions:

  <neighbor_name>      Interface name

[edit protocols rip]

jadmin@JR-1# set group rip-group export export-rip-routes neighbor em0.0

 

[edit protocols rip]

jadmin@JR-1# show

group rip-group {

    export export-rip-routes; ## 'export-rip-routes' is not defined

    neighbor em0.0;

}

 

[edit protocols rip]

 

 

Building Blocks of Routing Policy

 

A routing policy contains ordered groups of terms. A term is the basic building block of a Junos OS policy, which are essentially a series of if-then statements.

 

When evaluating the from statements, the Junos OS performs the evaluation as a logical OR between arguments to a single match criterion and a logical AND between different match criteria. For the from statement to be considered true, the item being evaluated must match at least one of the arguments to each given match criterion.

 

If a route matches all the conditions in the from statement of a term, the Junos OS executes all action specified in the then statement of the term. Provided that one of those actions is a terminating action, the evaluation of the policy stops.

 

The accept or reject of routes are terminating actions. Using these terminating actions results in a first-match policy evaluation because Junos OS takes the specified action immediately and performs no further evaluation of the policy.

 

You can use the insert command to modify the order in which terms appear.

 

You can select routes based on their prefix, protocol, routing protocol attributes or next-hop.

 

 

 

Prefix List

 

You can select routes based on their prefix using a prefix-list or a route filter. You can reference prefix-list in multiple terms in single policy or in different policies. You can reuse a prefix-list for both routing policy and firewall filter.

 

The prefix-list matches the prefix exactly while prefix-list-filter supports match types: exact, longer, orlonger.

 

jadmin@JR-1> configure

Entering configuration mode

Users currently editing the configuration:

  jadmin terminal p2 (pid 4022) on since 2020-10-21 01:14:03 SGT, idle 03:44:45

      [edit routing-options]

The configuration has been changed but not committed

 

[edit]

jadmin@JR-1# edit policy-options

 

[edit policy-options]

jadmin@JR-1# set prefix-list ?

Possible completions:

  <name>               Prefix list name

[edit policy-options]

jadmin@JR-1# set prefix-list rfc-1918 ?

Possible completions:

  <[Enter]>            Execute this command

  <prefix>             Address prefix

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  apply-path           Apply IP prefixes from a configuration statement

  dynamic-db           Object may exist in dynamic database

  |                    Pipe through a command

[edit policy-options]

jadmin@JR-1# set prefix-list rfc-1918 10.0.0.0/8 ?

Possible completions:

  <[Enter]>            Execute this command

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  |                    Pipe through a command

[edit policy-options]

jadmin@JR-1# set prefix-list rfc-1918 10.0.0.0/8

 

[edit policy-options]

jadmin@JR-1# set prefix-list rfc-1918 172.16.0.0/12

 

[edit policy-options]

jadmin@JR-1# set prefix-list rfc-1918 192.168.0.0/16

 

[edit policy-options]

jadmin@JR-1# set policy-statement ?

Possible completions:

  <policy_name>        Name to identify a policy filter

  export-rip-policy    Name to identify a policy filter

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  dynamic-db           Object may exist in dynamic database

> from                 Conditions to match the source of a route

> term                 Policy term

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 from ?

Possible completions:

  aggregate-contributor  Match more specifics of an aggregate

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  area                 OSPF area identifier

+ as-path              Name of AS path regular expression (BGP only)

+ as-path-group        Name of AS path group (BGP only)

  color                Color (preference) value

  color2               Color (preference) value 2

+ community            BGP community

> community-count      Number of BGP communities

+ condition            Condition to match on

> external             External route

  family

  instance             Routing protocol instance

+ interface            Interface name or address

  level                IS-IS level

  local-preference     Local preference associated with a route

  metric               Metric value

  metric2              Metric value 2

  metric3              Metric value 3

  metric4              Metric value 4

> multicast-scope      Multicast scope to match

+ neighbor             Neighboring router

+ next-hop             Next-hop router

  next-hop-type        Next-hop type

  origin               BGP origin attribute

+ policy               Name of policy to evaluate

  preference           Preference value

  preference2          Preference value 2

> prefix-list          List of prefix-lists of routes to match

> prefix-list-filter   List of prefix-list-filters to match

+ protocol             Protocol from which route was learned

  rib                  Routing table

> route-filter         List of routes to match

  route-type           Route type

> source-address-filter  List of source addresses to match

  state                Route state

+ tag                  Tag string

  tag2                 Tag string 2

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 from prefix-list ?

Possible completions:

  <prefix-list-name>   Name of prefix-list of routes to match

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 from prefix-list rfc-1918

 

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 then ?

Possible completions:

  accept               Accept a route

> aigp-originate       Originate a BGP AIGP attribute

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> as-path-expand       Prepend AS numbers prior to adding local-as (BGP only)

  as-path-prepend      Prepend AS numbers to an AS path (BGP only)

  class                Set class-of-service parameters

> color                Color (preference) value

> color2               Color (preference) value 2

> community            BGP community properties associated with a route

  cos-next-hop-map     Set CoS-based next-hop map in forwarding table

  damping              Define BGP route flap damping parameters

  default-action       Set default policy action

  destination-class    Set destination class in forwarding table

> external             External route

  forwarding-class     Set source or destination class in forwarding table

> install-nexthop      Choose the next hop to be used for forwarding

  label-allocation     Set label allocation mode

> load-balance         Type of load balancing in forwarding table

> local-preference     Local preference associated with a route

> map-to-interface     Set output logical interface

> metric               Metric value

> metric2              Metric value 2

> metric3              Metric value 3

> metric4              Metric value 4

  next                 Skip to next policy or term

> next-hop             Set the address of the next-hop router

  origin               BGP path origin

> preference           Preference value

> preference2          Preference value 2

  priority             Set priority for route installation

  reject               Reject a route

  source-class         Set source class in forwarding table

+ ssm-source           List of Sources for SSM mapping

> tag                  Tag string

> tag2                 Tag string 2

  trace                Log matches to a trace file

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 then reject

 

[edit policy-options]

jadmin@JR-1# set policy-statement pol-2 from prefix-list-filter ?

Possible completions:

  <list_name>          Name of prefix-list of routes to match

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

[edit policy-options]

jadmin@JR-1# set policy-statement pol-2 from prefix-list-filter rfc-1918 ?

Possible completions:

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

[edit policy-options]

jadmin@JR-1# set policy-statement pol-2 from prefix-list-filter rfc-1918 orlonger ?

Possible completions:

  <[Enter]>            Execute this command

  accept               Accept a route

> aigp-originate       Originate a BGP AIGP attribute

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> as-path-expand       Prepend AS numbers prior to adding local-as (BGP only)

  as-path-prepend      Prepend AS numbers to an AS path (BGP only)

  class                Set class-of-service parameters

> color                Color (preference) value

> color2               Color (preference) value 2

> community            BGP community properties associated with a route

  cos-next-hop-map     Set CoS-based next-hop map in forwarding table

  damping              Define BGP route flap damping parameters

  default-action       Set default policy action

  destination-class    Set destination class in forwarding table

  dynamic-db           Object may exist in dynamic database

> external             External route

  forwarding-class     Set source or destination class in forwarding table

> install-nexthop      Choose the next hop to be used for forwarding

  label-allocation     Set label allocation mode

> load-balance         Type of load balancing in forwarding table

> local-preference     Local preference associated with a route

> map-to-interface     Set output logical interface

> metric               Metric value

> metric2              Metric value 2

> metric3              Metric value 3

> metric4              Metric value 4

  next                 Skip to next policy or term

> next-hop             Set the address of the next-hop router

  origin               BGP path origin

> preference           Preference value

> preference2          Preference value 2

  priority             Set priority for route installation

  reject               Reject a route

  source-class         Set source class in forwarding table

+ ssm-source           List of Sources for SSM mapping

> tag                  Tag string

> tag2                 Tag string 2

  trace                Log matches to a trace file

  |                    Pipe through a command

[edit policy-options]

jadmin@JR-1# set policy-statement pol-2 from prefix-list-filter rfc-1918 orlonger reject

 

[edit policy-options]

jadmin@JR-1# show

prefix-list rfc-1918 {

    10.0.0.0/8;

    172.16.0.0/12;

    192.168.0.0/16;

}

policy-statement export-rip-policy {

    term match-rip-routes {

        from protocol rip;

        then accept;

    }

}

policy-statement pol-1 {

    from {

        prefix-list rfc-1918;

    }

    then reject;

}

policy-statement pol-2 {

    from {

        prefix-list-filter rfc-1918 orlonger reject;

    }

}

 

[edit policy-options]

 

 

Route Filters

 

Route filters are list of prefixes configured within a single routing policy term. Unlike prefix-list, they are not reusable but rather specific to the policy term which they are configured.

 

They provide a few more match types for selecting prefixes:

 

  • exact - the match type exact means that only routes that match the given prefix exactly match the filter statement.
  • orlonger - the match type orlonger means that routes with prefix length greater than or equal to the given prefix length match the filter statement.
  • longer - the match type longer means that routes with prefix length greater than the  given prefix length match the filter statement.
  • upto - the match type upto means that routes with prefix length greater than or equal to the given prefix length, but less than or equal to the upto prefix length match the filter statement.
  • prefix-length-range - the match type prefix-length-range means that routes with a prefix length greater than or equal to the first given prefix length, but less than or equal to the second prefix length match the filter statement.

 

 

jadmin@JR-1> configure

Entering configuration mode

The configuration has been changed but not committed

 

[edit]

jadmin@JR-1# edit policy-options

 

[edit policy-options]

jadmin@JR-1# set policy-statement ?

Possible completions:

  <policy_name>        Name to identify a policy filter

  export-rip-policy    Name to identify a policy filter

  pol-1                Name to identify a policy filter

  pol-2                Name to identify a policy filter

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  dynamic-db           Object may exist in dynamic database

> from                 Conditions to match the source of a route

> term                 Policy term

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term ?

Possible completions:

  <term_name>

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> from                 Conditions to match the source of a route

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from ?

Possible completions:

  aggregate-contributor  Match more specifics of an aggregate

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  area                 OSPF area identifier

+ as-path              Name of AS path regular expression (BGP only)

+ as-path-group        Name of AS path group (BGP only)

  color                Color (preference) value

  color2               Color (preference) value 2

+ community            BGP community

> community-count      Number of BGP communities

+ condition            Condition to match on

> external             External route

  family

  instance             Routing protocol instance

+ interface            Interface name or address

  level                IS-IS level

  local-preference     Local preference associated with a route

  metric               Metric value

  metric2              Metric value 2

  metric3              Metric value 3

  metric4              Metric value 4

> multicast-scope      Multicast scope to match

+ neighbor             Neighboring router

+ next-hop             Next-hop router

  next-hop-type        Next-hop type

  origin               BGP origin attribute

+ policy               Name of policy to evaluate

  preference           Preference value

  preference2          Preference value 2

> prefix-list          List of prefix-lists of routes to match

> prefix-list-filter   List of prefix-list-filters to match

+ protocol             Protocol from which route was learned

  rib                  Routing table

> route-filter         List of routes to match

  route-type           Route type

> source-address-filter  List of source addresses to match

  state                Route state

+ tag                  Tag string

  tag2                 Tag string 2

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from ?

Possible completions:

  aggregate-contributor  Match more specifics of an aggregate

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  area                 OSPF area identifier

+ as-path              Name of AS path regular expression (BGP only)

+ as-path-group        Name of AS path group (BGP only)

  color                Color (preference) value

  color2               Color (preference) value 2

+ community            BGP community

> community-count      Number of BGP communities

+ condition            Condition to match on

> external             External route

  family

  instance             Routing protocol instance

+ interface            Interface name or address

  level                IS-IS level

  local-preference     Local preference associated with a route

  metric               Metric value

  metric2              Metric value 2

  metric3              Metric value 3

  metric4              Metric value 4

> multicast-scope      Multicast scope to match

+ neighbor             Neighboring router

+ next-hop             Next-hop router

  next-hop-type        Next-hop type

  origin               BGP origin attribute

+ policy               Name of policy to evaluate

  preference           Preference value

  preference2          Preference value 2

> prefix-list          List of prefix-lists of routes to match

> prefix-list-filter   List of prefix-list-filters to match

+ protocol             Protocol from which route was learned

  rib                  Routing table

> route-filter         List of routes to match

  route-type           Route type

> source-address-filter  List of source addresses to match

  state                Route state

+ tag                  Tag string

  tag2                 Tag string 2

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from route-filter ?

Possible completions:

  <address>            IP address or hostname

  address-mask         Mask applied to prefix address

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

  prefix-length-range  Mask falls between two prefix lengths

  through              Route falls between two prefixes

  upto                 Mask falls between two prefix lengths

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from route-filter 172.16.0.0/12 ?

Possible completions:

  address-mask         Mask applied to prefix address

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

  prefix-length-range  Mask falls between two prefix lengths

  through              Route falls between two prefixes

  upto                 Mask falls between two prefix lengths

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from route-filter 172.16.0.0/12 orlonger

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from route-filter 192.168.0.0/16 longer

jadmin@JR-1# set policy-statement pol-1 term filter-rfc1918-prefix from route-filter 10.0.0.0/8 exact

 

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 then ?

Possible completions:

  accept               Accept a route

> aigp-originate       Originate a BGP AIGP attribute

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> as-path-expand       Prepend AS numbers prior to adding local-as (BGP only)

  as-path-prepend      Prepend AS numbers to an AS path (BGP only)

  class                Set class-of-service parameters

> color                Color (preference) value

> color2               Color (preference) value 2

> community            BGP community properties associated with a route

  cos-next-hop-map     Set CoS-based next-hop map in forwarding table

  damping              Define BGP route flap damping parameters

  default-action       Set default policy action

  destination-class    Set destination class in forwarding table

> external             External route

  forwarding-class     Set source or destination class in forwarding table

> install-nexthop      Choose the next hop to be used for forwarding

  label-allocation     Set label allocation mode

> load-balance         Type of load balancing in forwarding table

> local-preference     Local preference associated with a route

> map-to-interface     Set output logical interface

> metric               Metric value

> metric2              Metric value 2

> metric3              Metric value 3

> metric4              Metric value 4

  next                 Skip to next policy or term

> next-hop             Set the address of the next-hop router

  origin               BGP path origin

> preference           Preference value

> preference2          Preference value 2

  priority             Set priority for route installation

  reject               Reject a route

  source-class         Set source class in forwarding table

+ ssm-source           List of Sources for SSM mapping

> tag                  Tag string

> tag2                 Tag string 2

  trace                Log matches to a trace file

[edit policy-options]

jadmin@JR-1# set policy-statement pol-1 then reject

 

[edit policy-options]

jadmin@JR-1# show

prefix-list rfc-1918 {

    10.0.0.0/8;

    172.16.0.0/12;

    192.168.0.0/16;

}

policy-statement export-rip-policy {

    term match-rip-routes {

        from protocol rip;

        then accept;

    }

}

policy-statement pol-1 {

    term filter-rfc1918-prefix {

        from {

            route-filter 172.16.0.0/12 orlonger;

            route-filter 192.168.0.0/16 longer;

            route-filter 10.0.0.0/8 exact;

        }

    }

    from {

        prefix-list rfc-1918;

    }

    then reject;

}

policy-statement pol-2 {

    from {

        prefix-list-filter rfc-1918 orlonger reject;

    }

}

 

[edit policy-options]

 

 

 

jadmin@JR-1> test policy ?

Possible completions:

  <policy>             Policy name

jadmin@JR-1> test policy pol-1 ?

Possible completions:

  <prefix>             Destination prefix

jadmin@JR-1> test policy pol-1 192.168.0.0/16    // YOU CAN ALSO TEST THE EFFECTIVENESS OF THE CONFIGURED POLICY; NOTE THE DEFAULT IS ACCEPT ALL ROUTES

 

 

Common Actions

 

The accept and reject are some common terminating actions since they cause the evaluation of the policy to stop and accept or reject the route.

 

The default-action accept and default-action reject do not cause the evaluation policy to stop, but overrule the default policy's accept or reject determination.

 

The next term and next policy causes the Junos OS to evaluate the next term or next policy, respectively.

 

Other common actions modify routing protocol attributes such as BGP community, route preference, etc.

 

 

Defining Routing Policy

 

Two steps to define a routing policy:

  1. Define the routing policy under edit policy-options hierarchy level
  2. Apply the routing policy

 

 

jadmin@JR-1> configure

Entering configuration mode

Users currently editing the configuration:

  jadmin terminal v0 (pid 1480) on since 2020-10-21 12:35:46 SGT, idle 00:18:40

      [edit]

 

[edit]

jadmin@JR-1# edit policy-options

 

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  dynamic-db           Object may exist in dynamic database

> from                 Conditions to match the source of a route

> term                 Policy term

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term ?

Possible completions:

  <term_name>

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-local-routes ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> from                 Conditions to match the source of a route

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-local-routes from ?

Possible completions:

  aggregate-contributor  Match more specifics of an aggregate

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  area                 OSPF area identifier

+ as-path              Name of AS path regular expression (BGP only)

+ as-path-group        Name of AS path group (BGP only)

  color                Color (preference) value

  color2               Color (preference) value 2

+ community            BGP community

> community-count      Number of BGP communities

+ condition            Condition to match on

> external             External route

  family

  instance             Routing protocol instance

+ interface            Interface name or address

  level                IS-IS level

  local-preference     Local preference associated with a route

  metric               Metric value

  metric2              Metric value 2

  metric3              Metric value 3

  metric4              Metric value 4

> multicast-scope      Multicast scope to match

+ neighbor             Neighboring router

+ next-hop             Next-hop router

  next-hop-type        Next-hop type

  origin               BGP origin attribute

+ policy               Name of policy to evaluate

  preference           Preference value

  preference2          Preference value 2

> prefix-list          List of prefix-lists of routes to match

> prefix-list-filter   List of prefix-list-filters to match

+ protocol             Protocol from which route was learned

  rib                  Routing table

> route-filter         List of routes to match

  route-type           Route type

> source-address-filter  List of source addresses to match

  state                Route state

+ tag                  Tag string

  tag2                 Tag string 2

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-local-routes from protocol ?

Possible completions:

  [                    Open a set of values

  access               Access server routes

  access-internal      Internal routes to directly connected clients

  aggregate            Aggregate routes

  bgp                  BGP

  direct               Directly connected routes

  dvmrp                Distance Vector Multicast Routing Protocol

  esis                 End System-to-Intermediate System

  isis                 Intermediate System-to-Intermediate System

  l2circuit            Layer 2 circuits

  l2vpn                Layer 2 MPLS virtual private networks

  ldp                  Label Distribution Protocol

  local                Local system addresses

  msdp                 Multicast Source Discovery Protocol

  ospf                 Open Shortest Path First

  ospf2                Open Shortest Path First Version 2

  ospf3                Open Shortest Path First Version 3

  pim                  Protocol Independent Multicast

  rip                  Routing Information Protocol

  ripng                Routing Information Protocol next generation

  rsvp                 Resource Reservation Protocol

  rtarget              Local route target VPN membership

  static               Statically defined addresses

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-local-routes from protocol direct

jadmin@JR-1# set policy-statement pol1 term ?

Possible completions:

  <term_name>

  allow-local-routes

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-local-routes then ?

Possible completions:

  accept               Accept a route

> aigp-originate       Originate a BGP AIGP attribute

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> as-path-expand       Prepend AS numbers prior to adding local-as (BGP only)

  as-path-prepend      Prepend AS numbers to an AS path (BGP only)

  class                Set class-of-service parameters

> color                Color (preference) value

> color2               Color (preference) value 2

> community            BGP community properties associated with a route

  cos-next-hop-map     Set CoS-based next-hop map in forwarding table

  damping              Define BGP route flap damping parameters

  default-action       Set default policy action

  destination-class    Set destination class in forwarding table

> external             External route

  forwarding-class     Set source or destination class in forwarding table

> install-nexthop      Choose the next hop to be used for forwarding

  label-allocation     Set label allocation mode

> load-balance         Type of load balancing in forwarding table

> local-preference     Local preference associated with a route

> map-to-interface     Set output logical interface

> metric               Metric value

> metric2              Metric value 2

> metric3              Metric value 3

> metric4              Metric value 4

  next                 Skip to next policy or term

> next-hop             Set the address of the next-hop router

  origin               BGP path origin

> preference           Preference value

> preference2          Preference value 2

  priority             Set priority for route installation

  reject               Reject a route

  source-class         Set source class in forwarding table

+ ssm-source           List of Sources for SSM mapping

> tag                  Tag string

> tag2                 Tag string 2

  trace                Log matches to a trace file

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-local-routes then accept

 

jadmin@JR-1# set policy-statement pol1 term allow-static from protocol static

jadmin@JR-1# set policy-statement pol1 term allow-static from route-filter ?

Possible completions:

  <address>            IP address or hostname

  address-mask         Mask applied to prefix address

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

  prefix-length-range  Mask falls between two prefix lengths

  through              Route falls between two prefixes

  upto                 Mask falls between two prefix lengths

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-static from route-filter 172.18.1.0/24 ?

Possible completions:

  address-mask         Mask applied to prefix address

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

  prefix-length-range  Mask falls between two prefix lengths

  through              Route falls between two prefixes

  upto                 Mask falls between two prefix lengths

[edit policy-options]

jadmin@JR-1# set policy-statement pol1 term allow-static from route-filter 172.18.1.0/24 exact

jadmin@JR-1# set policy-statement pol1 term allow-static from route-filter 172.18.0.0/16 orlonger

jadmin@JR-1# set policy-statement pol1 term allow-static then accept

 

jadmin@JR-1# set policy-statement pol1 term allow-rip from protocol rip

jadmin@JR-1# set policy-statement pol1 term allow-rip then accept

 

[edit policy-options]

jadmin@JR-1# show

policy-statement pol1 {

    term allow-local-routes {

        from protocol direct;

        then accept;

    }

    term allow-static {

        from {

            protocol static;

            route-filter 172.18.1.0/24 exact;

            route-filter 172.18.0.0/16 orlonger;

        }

        then accept;

    }

    term allow-rip {

        from protocol rip;

        then accept;

    }

}

 

[edit policy-options]

 

 

Applying Routing Policy

 

Depending on the routing protocol, you can apply import and export policies at multiple hierarchy levels. Note OSPF only allows protocol-level export and import policies to maintain a consistent Link State Database (LSDB).

 

The Junos OS apply the most specific import and export policy. Import and export policies at higher configuration hierarchy levels are applied at the lower levels if no other policy exist. If you configure a policy at a lower hierarchy level, the system apply that policy.

 

[edit policy-options]

jadmin@JR-1# top edit protocols ospf

 

[edit protocols ospf]

jadmin@JR-1# set ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> area                 Configure an OSPF area

> backup-spf-options   Configure options for backup SPF

> database-protection  Configure database protection attributes

  disable              Disable OSPF

+ export               Export policy

  external-preference  Preference of external routes

> graceful-restart     Configure graceful restart attributes

+ import               Import policy (for external routes or setting priority)

  no-nssa-abr          Disable full NSSA functionality at ABR

  no-rfc-1583          Disable RFC1583 compatibility

> overload             Set the overload mode (repel transit traffic)

  preference           Preference of internal routes

  prefix-export-limit  Maximum number of prefixes that can be exported

  reference-bandwidth  Bandwidth for calculating metric defaults

  rib-group            Routing table group for importing OSPF routes

> spf-options          Configure options for SPF

> topology             Topology parameters

> traceoptions         Trace options for OSPF

> traffic-engineering  Configure traffic engineering attributes

[edit protocols ospf]

jadmin@JR-1# set export pol1 ?

Possible completions:

  <[Enter]>            Execute this command

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> area                 Configure an OSPF area

> backup-spf-options   Configure options for backup SPF

> database-protection  Configure database protection attributes

  disable              Disable OSPF

+ export               Export policy

  external-preference  Preference of external routes

> graceful-restart     Configure graceful restart attributes

+ import               Import policy (for external routes or setting priority)

  no-nssa-abr          Disable full NSSA functionality at ABR

  no-rfc-1583          Disable RFC1583 compatibility

> overload             Set the overload mode (repel transit traffic)

  preference           Preference of internal routes

  prefix-export-limit  Maximum number of prefixes that can be exported

  reference-bandwidth  Bandwidth for calculating metric defaults

  rib-group            Routing table group for importing OSPF routes

> spf-options          Configure options for SPF

> topology             Topology parameters

> traceoptions         Trace options for OSPF

> traffic-engineering  Configure traffic engineering attributes

  |                    Pipe through a command

[edit protocols ospf]

jadmin@JR-1# set export pol1 area 0.0.0.0 ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> area-range           Configure area ranges

> context-identifier   Configure context identifier in support of edge protection

> interface            Include an interface in this area

> label-switched-path  Configuration for advertisement of a label-switched path

+ network-summary-export  Export policy for Type 3 Summary LSAs

+ network-summary-import  Import policy for Type 3 Summary LSAs

  no-context-identifier-advertisement  Disable context identifier advertisments in this area

> peer-interface       Configuration for peer interface

> virtual-link         Configure virtual links

[edit protocols ospf]

jadmin@JR-1# set export pol1 area 0.0.0.0 interface em0.0 passive

 

[edit protocols ospf]

jadmin@JR-1# show

export pol1;

area 0.0.0.0 {

    interface em0.0 {

        passive;

    }

}

 

[edit protocols ospf]

 

 

Policy Chaining

 

You can cascade or chain a policy to solve a complex set of route manipulation task in a modular manner.

 

The Junos OS evaluates policies from left to right based on the order in which they are applied to a routing protocol. It checks the match criteria of each policy and performs the associated action when a match occurs. If the first policy does not match or if the match is associated with a nonterminating action, it evaluates the route against the next policy in the chain. This pattern repeats itself for all policies in the chain. The Junos OS ultimately applies the default policy for a given protocol when no terminating actions occur while evaluating the user-defined policy chain.

 

 

Case Study: Advertise default static route into OSPF routing policy

 


jadmin@JR1> configure

Entering configuration mode

Users currently editing the configuration:

  root terminal v0 (pid 1488) on since 2020-10-25 10:26:47 UTC, idle 00:53:36

      [edit system login]

 

[edit]

jadmin@JR1# edit routing-options

 

[edit routing-options]

jadmin@JR1# set static route 0.0.0.0/0 next-hop 10.1.1.10

 

[edit routing-options]

jadmin@JR1# top edit policy-options

 

[edit policy-options]

jadmin@JR1# set policy-statement ?

Possible completions:

  <policy_name>        Name to identify a policy filter

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  dynamic-db           Object may exist in dynamic database

> from                 Conditions to match the source of a route

> term                 Policy term

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term ?

Possible completions:

  <term_name>

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static ?

Possible completions:

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> from                 Conditions to match the source of a route

> then                 Actions to take if 'from' and 'to' conditions match

> to                   Conditions to match the destination of a route

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static from ?

Possible completions:

  aggregate-contributor  Match more specifics of an aggregate

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

  area                 OSPF area identifier

+ as-path              Name of AS path regular expression (BGP only)

+ as-path-group        Name of AS path group (BGP only)

  color                Color (preference) value

  color2               Color (preference) value 2

+ community            BGP community

> community-count      Number of BGP communities

+ condition            Condition to match on

> external             External route

  family

  instance             Routing protocol instance

+ interface            Interface name or address

  level                IS-IS level

  local-preference     Local preference associated with a route

  metric               Metric value

  metric2              Metric value 2

  metric3              Metric value 3

  metric4              Metric value 4

> multicast-scope      Multicast scope to match

+ neighbor             Neighboring router

+ next-hop             Next-hop router

  next-hop-type        Next-hop type

  origin               BGP origin attribute

+ policy               Name of policy to evaluate

  preference           Preference value

  preference2          Preference value 2

> prefix-list          List of prefix-lists of routes to match

> prefix-list-filter   List of prefix-list-filters to match

+ protocol             Protocol from which route was learned

  rib                  Routing table

> route-filter         List of routes to match

  route-type           Route type

> source-address-filter  List of source addresses to match

  state                Route state

+ tag                  Tag string

  tag2                 Tag string 2

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static from protocol ?

Possible completions:

  [                    Open a set of values

  access               Access server routes

  access-internal      Internal routes to directly connected clients

  aggregate            Aggregate routes

  bgp                  BGP

  direct               Directly connected routes

  dvmrp                Distance Vector Multicast Routing Protocol

  esis                 End System-to-Intermediate System

  isis                 Intermediate System-to-Intermediate System

  l2circuit            Layer 2 circuits

  l2vpn                Layer 2 MPLS virtual private networks

  ldp                  Label Distribution Protocol

  local                Local system addresses

  msdp                 Multicast Source Discovery Protocol

  ospf                 Open Shortest Path First

  ospf2                Open Shortest Path First Version 2

  ospf3                Open Shortest Path First Version 3

  pim                  Protocol Independent Multicast

  rip                  Routing Information Protocol

  ripng                Routing Information Protocol next generation

  rsvp                 Resource Reservation Protocol

  rtarget              Local route target VPN membership

  static               Statically defined addresses

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static from protocol static

 

jadmin@JR1# set policy-statement default-route-ospf term default-static from route-filter ?

Possible completions:

  <address>            IP address or hostname

  address-mask         Mask applied to prefix address

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

  prefix-length-range  Mask falls between two prefix lengths

  through              Route falls between two prefixes

  upto                 Mask falls between two prefix lengths

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static from route-filter 0.0.0.0/0 ?

Possible completions:

  address-mask         Mask applied to prefix address

  exact                Exactly match the prefix length

  longer               Mask is greater than the prefix length

  orlonger             Mask is greater than or equal to the prefix length

  prefix-length-range  Mask falls between two prefix lengths

  through              Route falls between two prefixes

  upto                 Mask falls between two prefix lengths

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static from route-filter 0.0.0.0/0 exact

 

jadmin@JR1# set policy-statement default-route-ospf term default-static then ?

Possible completions:

  accept               Accept a route

> aigp-originate       Originate a BGP AIGP attribute

+ apply-groups         Groups from which to inherit configuration data

+ apply-groups-except  Don't inherit configuration data from these groups

> as-path-expand       Prepend AS numbers prior to adding local-as (BGP only)

  as-path-prepend      Prepend AS numbers to an AS path (BGP only)

  class                Set class-of-service parameters

> color                Color (preference) value

> color2               Color (preference) value 2

> community            BGP community properties associated with a route

  cos-next-hop-map     Set CoS-based next-hop map in forwarding table

  damping              Define BGP route flap damping parameters

  default-action       Set default policy action

  destination-class    Set destination class in forwarding table

> external             External route

  forwarding-class     Set source or destination class in forwarding table

> install-nexthop      Choose the next hop to be used for forwarding

  label-allocation     Set label allocation mode

> load-balance         Type of load balancing in forwarding table

> local-preference     Local preference associated with a route

> map-to-interface     Set output logical interface

> metric               Metric value

> metric2              Metric value 2

> metric3              Metric value 3

> metric4              Metric value 4

  next                 Skip to next policy or term

> next-hop             Set the address of the next-hop router

  origin               BGP path origin

> preference           Preference value

> preference2          Preference value 2

  priority             Set priority for route installation

  reject               Reject a route

  source-class         Set source class in forwarding table

+ ssm-source           List of Sources for SSM mapping

> tag                  Tag string

> tag2                 Tag string 2

  trace                Log matches to a trace file

[edit policy-options]

jadmin@JR1# set policy-statement default-route-ospf term default-static then accept

 

[edit policy-options]

jadmin@JR1# show

policy-statement default-route-ospf {

    term default-static {

        from {

            protocol static;

            route-filter 0.0.0.0/0 exact;

        }

        then accept;

    }

}

 

 

[edit policy-options]

jadmin@JR1# top edit protocols ospf

 

[edit protocols ospf]

jadmin@JR1# set export ?

Possible completions:

  <value>              Export policy

  (                    Open an expression

  [                    Open a set of values

  default-route-ospf

[edit protocols ospf]

jadmin@JR1# set export default-route-ospf

 

[edit protocols ospf]

jadmin@JR1# show

export default-route-ospf;     // EXPORT (INJECT) DEFAULT STATIC ROUTE FROM ROUTING TABLE INTO OSPF

area 0.0.0.0 {

    interface em0.0 {

        passive;

    }

    interface em1.0;

    interface lo0.0;

}

 

[edit protocols ospf]

jadmin@JR1# commit and-quit

commit complete

Exiting configuration mode

 

 

jadmin@JR2> show route 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:01:51, metric 0, tag 0     // JR2 INSTALLS EXTERNAL OSPF ROUTE (PREFERENCE 150)

                    > to 172.25.1.1 via em0.0

10.1.1.0/24        *[OSPF/10] 00:33:51, metric 2

                    > to 172.25.1.1 via em0.0

172.20.1.1/32      *[OSPF/10] 00:33:51, metric 1

                    > to 172.25.1.1 via em0.0

224.0.0.5/32       *[OSPF/10] 00:38:09, metric 1

                      MultiRecv

 

jadmin@JR2> show route protocol ospf ?

Possible completions:

  <[Enter]>            Execute this command

  <destination>        IP address and optional prefix length of destination

  active-path          Show active paths

  advertising-protocol  Show information in format intended for particular routing protocol

  all                  Show all entries, including hidden entries

  aspath-regex         BGP AS path regular expression for entries to match

  best                 Show longest matching route

  brief                Display brief output

  ccc                  Name of entry in MPLS table with a circuit cross-connect interface

+ community            Identifier for community (can include wildcards)

  community-name       Name of configured community policy to match

  damping              Show entries subjected to particular kind of route damping

  detail               Display detailed output

  exact                Show routes that match exactly

  extensive            Display extensive output

  hidden               Show hidden entries

  inactive-path        Show inactive paths

  inactive-prefix      Show inactive route destinations

  label                Label of entry in MPLS routing table

  label-switched-path  Name of LSP tunnel associated with entries

  logical-system       Name of logical system, or 'all'

  match-prefix         Regular expression to match formatted prefix

  next-hop             IP address of next hop that is destination for entries

  no-community         Show entries with no associated community

  output               Show entries sent out a particular interface

  private              Show private table routes

  range                Show all entries in prefix range

  rd-prefix            Route distinguisher with ip prefix (rd:prefix)

  receive-protocol     Show information in format received from particular routing protocol

  source-gateway       IP address of source router for entries

  static-label-switched-path  Name of static LSP tunnel associated with entries

  table                Name of routing table

  terse                Display terse output

  |                    Pipe through a command

jadmin@JR2> show route protocol ospf exact ?

Possible completions:

  <[Enter]>            Execute this command

  <destination>        IP address and optional prefix length of destination

  active-path          Show active paths

  advertising-protocol  Show information in format intended for particular routi

ng protocol

  all                  Show all entries, including hidden entries

  aspath-regex         BGP AS path regular expression for entries to match

  brief                Display brief output

  ccc                  Name of entry in MPLS table with a circuit cross-connect

interface

+ community            Identifier for community (can include wildcards)

  community-name       Name of configured community policy to match

  damping              Show entries subjected to particular kind of route damping

  detail               Display detailed output

  extensive            Display extensive output

  hidden               Show hidden entries

  inactive-path        Show inactive paths

  inactive-prefix      Show inactive route destinations

  label                Label of entry in MPLS routing table

  label-switched-path  Name of LSP tunnel associated with entries

  logical-system       Name of logical system, or 'all'

  match-prefix         Regular expression to match formatted prefix

  next-hop             IP address of next hop that is destination for entries

  no-community         Show entries with no associated community

  output               Show entries sent out a particular interface

  private              Show private table routes

  rd-prefix            Route distinguisher with ip prefix (rd:prefix)

  receive-protocol     Show information in format received from particular routing protocol

  source-gateway       IP address of source router for entries

  static-label-switched-path  Name of static LSP tunnel associated with entries

  table                Name of routing table

  terse                Display terse output

  |                    Pipe through a command

jadmin@JR2> show route protocol ospf exact 0/0

 

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:02:11, metric 0, tag 0  

                    > to 172.25.1.1 via em0.0

 

 

Below are the configurations for JR1 and JR2, respectively.

 

JR1

 

edit routing-options

 

set static route 0.0.0.0/0 next-hop 10.1.1.10

 

top edit policy-options

 

set policy-statement default-route-ospf term default-static from protocol static

 

set policy-statement default-route-ospf term default-static from route-filter 0.0.0.0/0 exact

 

set policy-statement default-route-ospf term default-static then accept

 

show

 

top edit protocols ospf

 

set export default-route-ospf

 

show

 

commit and-quit

 

 

 

JR2

 

show route protocol ospf

 

show route protocol ospf exact 0/0