Description

This article provides an example of how to configure source-based routing on SRX

Symptoms

  • How to configure Filter Based Forwarding to route packets, which are based on source and destination routes.
  • The default behavior is to configure the route based on only destination routes. 
  • In this example, Filter Based Forwarding (FBF) will select how traffic is to be routed to either ISP1 or ISP2.

Solution

To explain source-based routing on SRX, an example of two groups of users is used; one that will go through a lower bandwidth (ISP1) and the other group of users will go through a higher bandwidth (ISP2).

Assume that the PCs from 192.168.10.2 to 192.168.10.126 will go through ISP1. Similarly, PCs from 192.168.10.129 to 192.168.10.254 will go through ISP2.  All PCs will come in via ge-0/0/0.0 , ISP1 is connected to fe-0/0/2.0 , and ISP2 is connected to fe-0/0/3.0 .
 

interfaces {                           
    ge-0/0/0 {
        unit 0 {
            family inet {
                filter {
                    input 2nd-ISP;
                }
                address 192.168.10.128/24;
            }
        }
    }
    fe-0/0/2 {
        unit 0 {
            description ISP1;
            family inet {
                address 1.1.1.1/24;
            }
        }
    }
    fe-0/0/3 {
        unit 0 {
            description ISP2;
            family inet {
                address 1.2.2.1/24;   
            }
        }
    }
}
Configure a firewall family inet filter which is based on the source address of the PCs on the higher bandwidth ISP. Once the interested source IP range is filtered, you can then forward to the routing-instance of the ISP2 routing table.
firewall {
    family inet {
        filter 2nd-ISP {
            term 0 {
                from {
                    source-address {
                        192.168.10.128/25;
                    }
                }
                then {
                    routing-instance 2nd-router;
                }
            }
            term 1 {
                then accept;
            }
        }
    }
   
}
You can then configure the routing-instance in which the packet will be forwarded for ISP2.
routing-instances {
    2nd-router {
        instance-type forwarding;
        routing-options {               
            static {
                route 0.0.0.0/0 next-hop 1.2.2.254;
            }
        }
    }
}

You can now directly import the connected routes into the routing-tables for the appropriate routing-instance.
routing-options {
    interface-routes {
        rib-group inet 2nd-router;
    }
    static {
         route 0.0.0.0/0 next-hop 1.1.1.254;
    }
    rib-groups {
        2nd-router {
            import-rib [inet.0 2nd-router.inet.0];
        }
    }
}

Modification History

2025-04-22: Updated technical documentation link in Related Information

2024-10-14: minor non tech changes

2020-03-25: Article reviewed for accuracy; it is valid and accurate 

Related Information