- play_arrow Understanding and Configuring Junos Routing Policies
- play_arrow Overview
- Policy Framework Overview
- Comparison of Routing Policies and Firewall Filters
- Prefix Prioritization Overview
- FIB Prefix Prioritization
- Accounting of the Policer Overhead Attribute at the Interface Level
- Configuring the Accounting of Policer Overhead in Interface Statistics
- Understanding Routing Policies
- Protocol Support for Import and Export Policies
- Example: Applying Routing Policies at Different Levels of the BGP Hierarchy
- Default Routing Policies
- Example: Configuring a Conditional Default Route Policy
- play_arrow Evaluating Routing Policies Using Match Conditions, Actions, Terms, and Expressions
- How a Routing Policy Is Evaluated
- Categories of Routing Policy Match Conditions
- Routing Policy Match Conditions
- Route Filter Match Conditions
- Actions in Routing Policy Terms
- Summary of Routing Policy Actions
- Example: Configuring a Routing Policy to Advertise the Best External Route to Internal Peers
- Example: Configuring BGP to Advertise Inactive Routes
- Example: Using Routing Policy to Set a Preference Value for BGP Routes
- Example: Enabling BGP Route Advertisements
- Example: Rejecting Known Invalid Routes
- Example: Using Routing Policy in an ISP Network
- Understanding Policy Expressions
- Understanding Backup Selection Policy for OSPF Protocol
- Configuring Backup Selection Policy for the OSPF Protocol
- Configuring Backup Selection Policy for IS-IS Protocol
- Example: Configuring Backup Selection Policy for the OSPF or OSPF3 Protocol
- play_arrow Evaluating Complex Cases Using Policy Chains and Subroutines
- play_arrow Configuring Route Filters and Prefix Lists as Match Conditions
- Understanding Route Filters for Use in Routing Policy Match Conditions
- Understanding Route Filter and Source Address Filter Lists for Use in Routing Policy Match Conditions
- Understanding Load Balancing Using Source or Destination IP Only
- Configuring Load Balancing Using Source or Destination IP Only
- Walkup for Route Filters Overview
- Configuring Walkup for Route Filters to Improve Operational Efficiency
- Example: Configuring Route Filter Lists
- Example: Configuring Walkup for Route Filters Globally to Improve Operational Efficiency
- Example: Configuring Walkup for Route Filters Locally to Improve Operational Efficiency
- Example: Configuring a Route Filter Policy to Specify Priority for Prefixes Learned Through OSPF
- Example: Configuring the MED Using Route Filters
- Example: Configuring Layer 3 VPN Protocol Family Qualifiers for Route Filters
- Understanding Prefix Lists for Use in Routing Policy Match Conditions
- Example: Configuring Routing Policy Prefix Lists
- Example: Configuring the Priority for Route Prefixes in the RPD Infrastructure
- Configuring Priority for Route Prefixes in RPD Infrastructure
- play_arrow Configuring AS Paths as Match Conditions
- Understanding AS Path Regular Expressions for Use as Routing Policy Match Conditions
- Example: Using AS Path Regular Expressions
- Understanding Prepending AS Numbers to BGP AS Paths
- Example: Configuring a Routing Policy for AS Path Prepending
- Understanding Adding AS Numbers to BGP AS Paths
- Example: Advertising Multiple Paths in BGP
- Improve the Performance of AS Path Lookup in BGP Policy
- play_arrow Configuring Communities as Match Conditions
- Understanding BGP Communities, Extended Communities, and Large Communities as Routing Policy Match Conditions
- Understanding How to Define BGP Communities and Extended Communities
- How BGP Communities and Extended Communities Are Evaluated in Routing Policy Match Conditions
- Example: Configuring Communities in a Routing Policy
- Example: Configuring Extended Communities in a Routing Policy
- Example: Configuring BGP Large Communities
- Example: Configuring a Routing Policy Based on the Number of BGP Communities
- Example: Configuring a Routing Policy That Removes BGP Communities
- play_arrow Increasing Network Stability with BGP Route Flapping Actions
- play_arrow Tracking Traffic Usage with Source Class Usage and Destination Class Usage Actions
- Understanding Source Class Usage and Destination Class Usage Options
- Source Class Usage Overview
- Guidelines for Configuring SCU
- System Requirements for SCU
- Terms and Acronyms for SCU
- Roadmap for Configuring SCU
- Roadmap for Configuring SCU with Layer 3 VPNs
- Configuring Route Filters and Source Classes in a Routing Policy
- Applying the Policy to the Forwarding Table
- Enabling Accounting on Inbound and Outbound Interfaces
- Configuring Input SCU on the vt Interface of the Egress PE Router
- Mapping the SCU-Enabled vt Interface to the VRF Instance
- Configuring SCU on the Output Interface
- Associating an Accounting Profile with SCU Classes
- Verifying Your SCU Accounting Profile
- SCU Configuration
- SCU with Layer 3 VPNs Configuration
- Example: Grouping Source and Destination Prefixes into a Forwarding Class
- play_arrow Avoiding Traffic Routing Threats with Conditional Routing Policies
- Conditional Advertisement and Import Policy (Routing Table) with certain match conditions
- Conditional Advertisement Enabling Conditional Installation of Prefixes Use Cases
- Example: Configuring a Routing Policy for Conditional Advertisement Enabling Conditional Installation of Prefixes in a Routing Table
- play_arrow Protecting Against DoS Attacks by Forwarding Traffic to the Discard Interface
- play_arrow Improving Commit Times with Dynamic Routing Policies
- play_arrow Testing Before Applying Routing Policies
-
- play_arrow Configuring Traffic Policers
- play_arrow Understanding Traffic Policers
- Policer Implementation Overview
- ARP Policer Overview
- Example: Configuring ARP Policer
- Understanding the Benefits of Policers and Token Bucket Algorithms
- Determining Proper Burst Size for Traffic Policers
- Controlling Network Access Using Traffic Policing Overview
- Traffic Policer Types
- Order of Policer and Firewall Filter Operations
- Understanding the Frame Length for Policing Packets
- Supported Standards for Policing
- Hierarchical Policer Configuration Overview
- Understanding Enhanced Hierarchical Policers
- Packets-Per-Second (pps)-Based Policer Overview
- Guidelines for Applying Traffic Policers
- Policer Support for Aggregated Ethernet Interfaces Overview
- Example: Configuring a Physical Interface Policer for Aggregate Traffic at a Physical Interface
- Firewall and Policing Differences Between PTX Series Packet Transport Routers and T Series Matrix Routers
- Hierarchical Policers on ACX Series Routers Overview
- Guidelines for Configuring Hierarchical Policers on ACX Series Routers
- Hierarchical Policer Modes on ACX Series Routers
- Processing of Hierarchical Policers on ACX Series Routers
- Actions Performed for Hierarchical Policers on ACX Series Routers
- Configuring Aggregate Parent and Child Policers on ACX Series Routers
- play_arrow Configuring Policer Rate Limits and Actions
- play_arrow Configuring Layer 2 Policers
- Hierarchical Policers
- Configuring a Policer Overhead
- Two-Color and Three-Color Policers at Layer 2
- Layer 2 Traffic Policing at the Pseudowire Overview
- Configuring a Two-Color Layer 2 Policer for the Pseudowire
- Configuring a Three-Color Layer 2 Policer for the Pseudowire
- Applying the Policers to Dynamic Profile Interfaces
- Attaching Dynamic Profiles to Routing Instances
- Using Variables for Layer 2 Traffic Policing at the Pseudowire Overview
- Configuring a Policer for the Complex Configuration
- Creating a Dynamic Profile for the Complex Configuration
- Attaching Dynamic Profiles to Routing Instances for the Complex Configuration
- Verifying Layer 2 Traffic Policers on VPLS Connections
- Understanding Policers on OVSDB-Managed Interfaces
- Example: Applying a Policer to OVSDB-Managed Interfaces
- play_arrow Configuring Two-Color and Three-Color Traffic Policers at Layer 3
- Two-Color Policer Configuration Overview
- Basic Single-Rate Two-Color Policers
- Bandwidth Policers
- Prefix-Specific Counting and Policing Actions
- Policer Overhead to Account for Rate Shaping in the Traffic Manager
- Three-Color Policer Configuration Overview
- Applying Policers
- Three-Color Policer Configuration Guidelines
- Basic Single-Rate Three-Color Policers
- Basic Two-Rate Three-Color Policers
- Example: Configuring a Two-Rate Three-Color Policer
- play_arrow Configuring Logical and Physical Interface Traffic Policers at Layer 3
- play_arrow Configuring Policers on Switches
- Overview of Policers
- Traffic Policer Types
- Understanding the Use of Policers in Firewall Filters
- Understanding Tricolor Marking Architecture
- Configuring Policers to Control Traffic Rates (CLI Procedure)
- Configuring Tricolor Marking Policers
- Understanding Policers with Link Aggregation Groups
- Understanding Color-Blind Mode for Single-Rate Tricolor Marking
- Understanding Color-Aware Mode for Single-Rate Tricolor Marking
- Understanding Color-Blind Mode for Two-Rate Tricolor Marking
- Understanding Color-Aware Mode for Two-Rate Tricolor Marking
- Example: Using Two-Color Policers and Prefix Lists
- Example: Using Policers to Manage Oversubscription
- Assigning Forwarding Classes and Loss Priority
- Configuring Color-Blind Egress Policers for Medium-Low PLP
- Configuring Two-Color and Three-Color Policers to Control Traffic Rates
- Verifying That Two-Color Policers Are Operational
- Verifying That Three-Color Policers Are Operational
- Troubleshooting Policer Configuration
- Troubleshooting Policer Configuration
-
- play_arrow Configuration Statements and Operational Commands
- play_arrow Troubleshooting
- play_arrow Knowledge Base
-
ON THIS PAGE
Example: Configuring Filter-Based Forwarding on the Source Address
This example shows how to configure filter-based forwarding (FBF), which is sometimes also called Policy Based Routing (PBR). The filter classifies packets to determine their forwarding path within the ingress routing device.
Filter-based forwarding is supported for IP version 4 (IPv4) and IP version 6 (IPv6).
QFX5110, QFX5120, QFX5130, QFX5200, QFX5210, QFX5220, QFX5230, QFX5240, and QFX5700
do not support instance-type forwarding
; only instance-type
virtual-router
is supported.
Overview
In this example, we use FBF for service provider selection when customers have Internet connectivity provided by different ISPs yet share a common access layer. When a shared media (such as a cable modem) is used, a mechanism on the common access layer looks at Layer 2 or Layer 3 addresses and distinguishes between customers. You can use filter-based forwarding when the common access layer is implemented using a combination of Layer 2 switches and a single router.
With FBF, all packets received on an interface are considered. Each packet passes through a filter that has match conditions. If the match conditions are met for a filter and you have created a routing instance, FBF is applied to the packet. The packet is forwarded based on the next hop specified in the routing instance. For static routes, the next hop can be a specific LSP.
Source-class usage filter matching and unicast reverse-path forwarding checks are not supported on an interface configured for FBF.
To configure FBF, perform the following tasks:
Create a match filter on the ingress device. To specify a match filter, include the
filter filter-name
statement at the[edit firewall]
hierarchy level. A packet that passes through the filter is compared against a set of rules to classify it and to determine its membership in a set. Once classified, the packet is forwarded to a routing table specified in the accept action in the filter description language. The routing table then forwards the packet to the next hop that corresponds to the destination address entry in the table.Create routing instances that specify the routing table(s) to which a packet is forwarded, and the destination to which the packet is forwarded at the
[edit routing-instances]
hierarchy level. For example:content_copy zoom_out_map[edit] routing-instances { routing-table-name1 { instance-type forwarding; routing-options { static { route 0.0.0.0/0 next-hop 172.16.0.14; } } } routing-table-name2 { instance-type forwarding; routing-options { static { route 0.0.0.0/0 next-hop 172.16.0.18; } } } }
Create a RIB group to share interface routes with the forwarding routing instances used in filter-based forwarding (FBF). This part of the configuration resolves the routes installed in the routing instances to directly connected next hops on that interface. Create the routing table group at the
[edit routing-options]
hierarchy level.content_copy zoom_out_map[edit] routing-options { interface-routes { rib-group; inet { int-routes; } } } } routing-options { rib-groups { int-routes { import-rib { inet.0; webtraffic.inet.0; } } } }
This example shows a packet filter that directs customer traffic to a next-hop router in the domains, SP1 or SP2, based on the packet’s source address.
If the packet has a source address assigned to an SP1 customer, destination-based forwarding occurs using the sp1-route-table.inet.0 routing table. If the packet has a source address assigned to an SP2 customer, destination-based forwarding occurs using the sp2-route-table.inet.0 routing table. If a packet does not match either of these conditions, the filter accepts the packet, and destination-based forwarding occurs using the standard inet.0 routing table.
Topology
Figure 1 shows the topology used in this example.
On Device P1, an input filter classifies packets received from Device PE3 and Device PE4. The packets are routed based on the source addresses. Packets with source addresses in the 10.1.1.0/24 and 10.1.2.0/24 networks are routed to Device PE1. Packets with source addresses in the 10.2.1.0/24 and 10.2.2.0/24 networks are routed to Device PE2.

To establish connectivity, OSPF is configured on all of the interfaces. For demonstration purposes, loopback interface addresses are configured on the routing devices to represent networks in the clouds.
The CLI Quick Configuration section shows the entire configuration for all of the devices in the topology. The Configuring Filter-Based Forwarding on Device P1 section shows the step-by-step configuration of the ingress routing device, Device P1.
Configuration
- CLI Quick Configuration
- Configuring the Firewall Filter on P1
- Configuring Filter-Based Forwarding on Device P1
- Results
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 P1
set firewall filter classify-customers term sp1-customers from source-address 10.1.1.0/24 set firewall filter classify-customers term sp1-customers from source-address 10.1.2.0/24 set firewall filter classify-customers term sp1-customers then log set firewall filter classify-customers term sp1-customers then routing-instance sp1-route-table set firewall filter classify-customers term sp2-customers from source-address 10.2.1.0/24 set firewall filter classify-customers term sp2-customers from source-address 10.2.2.0/24 set firewall filter classify-customers term sp2-customers then log set firewall filter classify-customers term sp2-customers then routing-instance sp2-route-table set firewall filter classify-customers term default then accept set interfaces fe-1/2/0 unit 0 family inet filter input classify-customers set interfaces fe-1/2/0 unit 0 family inet address 172.16.0.10/30 set interfaces fe-1/2/1 unit 0 family inet address 172.16.0.13/30 set interfaces fe-1/2/2 unit 0 family inet address 172.16.0.17/30 set protocols ospf rib-group fbf-group set protocols ospf area 0.0.0.0 interface all set protocols ospf area 0.0.0.0 interface fxp0.0 disable set routing-instances sp1-route-table instance-type forwarding set routing-instances sp1-route-table routing-options static route 0.0.0.0/0 next-hop 172.16.0.14 set routing-instances sp2-route-table instance-type forwarding set routing-instances sp2-route-table routing-options static route 0.0.0.0/0 next-hop 172.16.0.18 set routing-options interface-routes rib-group fbf-group set routing-options rib-groups fbf-group import-rib inet.0 set routing-options rib-groups fbf-group import-rib sp1-route-table.inet.0 set routing-options rib-groups fbf-group import-rib sp2-route-table.inet.0
Device P2
set interfaces fe-1/2/0 unit 0 family inet address 172.16.0.2/30 set interfaces fe-1/2/1 unit 0 family inet address 172.16.0.6/30 set interfaces fe-1/2/2 unit 0 family inet address 172.16.0.9/30 set protocols ospf area 0.0.0.0 interface all set protocols ospf area 0.0.0.0 interface fxp0.0 disable
Device PE1
set interfaces fe-1/2/0 unit 0 family inet address 172.16.0.14/30 set interfaces lo0 unit 0 family inet address 172.16.1.1/32 set protocols ospf area 0.0.0.0 interface all set protocols ospf area 0.0.0.0 interface fxp0.0 disable
Device PE2
set interfaces fe-1/2/0 unit 0 family inet address 172.16.0.18/30 set interfaces lo0 unit 0 family inet address 172.16.2.2/32 set protocols ospf area 0.0.0.0 interface all set protocols ospf area 0.0.0.0 interface fxp0.0 disable
Device PE3
set interfaces fe-1/2/0 unit 0 family inet address 172.16.0.1/30 set interfaces lo0 unit 0 family inet address 10.1.1.1/32 set interfaces lo0 unit 0 family inet address 10.1.2.1/32 set protocols ospf area 0.0.0.0 interface all set protocols ospf area 0.0.0.0 interface fxp0.0 disable
Device PE4
set interfaces fe-1/2/0 unit 0 family inet address 172.16.0.5/30 set interfaces lo0 unit 0 family inet address 10.2.1.1/32 set interfaces lo0 unit 0 family inet address 10.2.2.1/32 set protocols ospf area 0.0.0.0 interface all set protocols ospf area 0.0.0.0 interface fxp0.0 disable
Configuring the Firewall Filter on P1
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 Junos OS CLI User Guide.
To configure the firewall filter on the main router or switch:
Configure the source addresses for SP1 customers.
content_copy zoom_out_map[edit firewall filter classify-customers term sp1-customers] user@host# set from source-address 10.1.1.0/24 user@host# set from source-address 10.1.2.0/24
Configure the actions that are taken when packets are received with the specified source addresses; they are logged, and they are passed to the sp1-route-table routing instance for routing via the sp1-route-table.inet.0 routing table.
content_copy zoom_out_map[edit firewall filter classify-customers term sp1-customers] user@host# set then log user@host# set then routing-instance sp1-route-table
Configure the source addresses for SP2 customers.
content_copy zoom_out_map[edit firewall filter classify-customers term sp2-customers] user@host# set from source-address 10.2.1.0/24 user@host# set from source-address 10.2.2.0/24
Configure the actions that are taken when packets are received with the specified source addresses; they are logged, and they are passed to the sp2-route-table routing instance for routing via the sp2-route-table.inet.0 routing table.
content_copy zoom_out_map[edit firewall filter classify-customers term sp2-customers] user@host# set then log user@host# set then routing-instance sp2-route-table
Configure the action to take when packets are received from any other source address; they are accepted and routed using the default IPv4 unicast routing table, inet.0.
content_copy zoom_out_map[edit firewall filter classify-customers term default] user@host# set then accept
Configuring Filter-Based Forwarding on Device P1
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 Junos OS CLI User Guide.
To configure the routing instances:
Configure the interfaces.
content_copy zoom_out_map[edit interfaces fe-1/2/0] user@host# set unit 0 family inet address 172.16.0.10/30 [edit interfaces fe-1/2/1] user@host# set unit 0 family inet address 172.16.0.13/30 [edit interfaces fe-1/2/2] user@host# set unit 0 family inet address 172.16.0.17/30
Assign the
classify-customers
firewall filter to router interface fe-1/2/0.0 as an input packet filter.content_copy zoom_out_map[edit interfaces fe-1/2/0] user@host# set unit 0 family inet filter input classify-customers
Configure connectivity, using either a routing protocol or static routing.
As a best practice, disable routing on the management interface.
content_copy zoom_out_map[edit protocols ospf area 0.0.0.0] user@host# set interface all user@host# set interface fxp0.0 disable
Create the routing instances that are referenced in the
classify-customers
firewall filter. The forwarding instance type provides support for filter-based forwarding, where interfaces are not associated with instances.content_copy zoom_out_map[edit routing-instances] user@host# set sp1-route-table instance-type forwarding user@host# set sp2-route-table instance-type forwarding
For each routing instance, define a default route to forward traffic to the specified next hop (PE1 and PE2 in this example).
content_copy zoom_out_map[edit routing-instances ] user@host# set sp1-route-table routing-options static route 0.0.0.0/0 next-hop 172.16.0.14 user@host# set sp2-route-table routing-options static route 0.0.0.0/0 next-hop 172.16.0.18
Associate the routing tables to form a routing table group. The first routing table, inet.0, is the primary routing table, and the others are secondary routing tables. The primary routing table determines the address family of the routing table group, in this case IPv4.
content_copy zoom_out_map[edit routing-options] user@host# set rib-groups fbf-group import-rib inet.0 user@host# set rib-groups fbf-group import-rib sp1-route-table.inet.0 user@host# set rib-groups fbf-group import-rib sp2-route-table.inet.0
Specify the fbf-group routing table group within the OSPF configuration to install OSPF routes into the three routing tables.
content_copy zoom_out_map[edit protocols ospf] user@host# set rib-group fbf-group
Commit the configuration when you are done.
content_copy zoom_out_map[edit] user@host# commit
Results
Confirm your configuration by issuing the show
interfaces
, show firewall
, show protocols
, show routing-instances
, and show routing-options
commands.
user@host# show interfaces fe-1/2/0 { unit 0 { family inet { filter { input classify-customers; } address 172.16.0.10/30; } } } fe-1/2/1 { unit 0 { family inet { address 172.16.0.13/30; } } } fe-1/2/2 { unit 0 { family inet { address 172.16.0.17/30; } } }
user@host# show firewall filter classify-customers { term sp1-customers { from { source-address { 10.1.1.0/24; 10.1.2.0/24; } } then { log; routing-instance sp1-route-table; } } term sp2-customers { from { source-address { 10.2.1.0/24; 10.2.2.0/24; } } then { log; routing-instance sp2-route-table; } } term default { then accept; } }
user@host# show protocols ospf { rib-group fbf-group; area 0.0.0.0 { interface all; interface fxp0.0 { disable; } } }
user@host# show routing-instances sp1-route-table { instance-type forwarding; routing-options { static { route 0.0.0.0/0 next-hop 172.16.0.14; } } } sp2-route-table { instance-type forwarding; routing-options { static { route 0.0.0.0/0 next-hop 172.16.0.18; } } }
user@host# show routing-options rib-groups { fbf-group { import-rib [ inet.0 sp1-route-table.inet.0 sp2-route-table.inet.0 ]; } }
Verification
Confirm that the configuration is working properly.
Pinging with Specified Source Addresses
Purpose
Send some ICMP packets across the network to test the firewall filter.
Action
Run the
ping
command, pinging the lo0.0 interface on Device PE1.The address configured on this interface is 172.16.1.1.
Specify the source address 10.1.2.1, which is the address configured on the lo0.0 interface on Device PE3.
content_copy zoom_out_mapuser@PE3> ping 172.16.1.1 source 10.1.2.1 PING 172.16.1.1 (172.16.1.1): 56 data bytes 64 bytes from 172.16.1.1: icmp_seq=0 ttl=62 time=1.444 ms 64 bytes from 172.16.1.1: icmp_seq=1 ttl=62 time=2.094 ms ^C --- 172.16.1.1 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 1.444/1.769/2.094/0.325 ms
Run the
ping
command, pinging the lo0.0 interface on Device PE2.The address configured on this interface is 172.16.2.2.
Specify the source address 10.2.1.1, which is the address configured on the lo0.0 interface on Device PE4.
content_copy zoom_out_mapuser@PE4> ping 172.16.2.2 source 10.2.1.1 PING 172.16.2.2 (172.16.2.2): 56 data bytes 64 bytes from 172.16.2.2: icmp_seq=0 ttl=62 time=1.473 ms 64 bytes from 172.16.2.2: icmp_seq=1 ttl=62 time=1.407 ms ^C --- 172.16.2.2 ping statistics --- 2 packets transmitted, 2 packets received, 0% packet loss round-trip min/avg/max/stddev = 1.407/1.440/1.473/0.033 ms
Meaning
Sending these pings activates the firewall filter actions.
Verifying the Firewall Filter
Purpose
Make sure the firewall filter actions take effect.
Action
Run the
show firewall log
command on Device P1.content_copy zoom_out_mapuser@P1> show firewall log Log : Time Filter Action Interface Protocol Src Addr Dest Addr 13:52:20 pfe A fe-1/2/0.0 ICMP 10.2.1.1 172.16.2.2 13:52:19 pfe A fe-1/2/0.0 ICMP 10.2.1.1 172.16.2.2 13:51:53 pfe A fe-1/2/0.0 ICMP 10.1.2.1 172.16.1.1 13:51:52 pfe A fe-1/2/0.0 ICMP 10.1.2.1 172.16.1.1