Policy-Based Routes (PBR) for IPv4 Traffic
Configuring PBRs involves the following tasks:
- Create a PBR.
- Apply PBRs.
- (Optional) Disable or enable a PBR.
- (Optional) Renumber the priority of the PBR.
Creating or Modifying a PBR
You cannot create two PBRs with the same parameters. If you attempt to create a duplicate, an error message appears.
You can configure the priority of a PBR. The priority (an integer value) defines the order in which the Citrix ADC appliance evaluates PBRs. When you create a PBR without specifying a priority, the Citrix ADC automatically assigns a priority that is a multiple of 10.
If a packet matches the condition defined by the PBR, the Citrix ADC performs an action. If the packet does not match the condition defined by the PBR, the Citrix ADC compares the packet against the PBR with the next highest priority.
Instead of sending the selected packets to a next hop router, you can configure the PBR to send them to a link load balancing virtual server to which you have bound multiple next hops. This configuration can provide a backup if a next hop link fails.
Consider the following example. Two PBRs, p1 and p2, are configured on the Citrix ADC and automatically assigned priorities 20 and 30. You need to add a third PBR, p3, to be evaluated immediately after the first PBR, p1. The new PBR, p3, must have a priority between 20 and 30. In this case, you can specify the priority as 25.
CLI procedures
To create a PBR by using the CLI:
At the command prompt, type:
- add ns pbr <name> <action> [-srcIP [<operator>] <srcIPVal>] [-srcPort [<operator>] <srcPortVal>] [-destIP [<operator>] <destIPVal>] [-destPort [<operator>] <destPortVal>] [-nextHop <nextHopVal>] [-srcMac <mac_addr>] [-protocol <protocol> |-protocolNumber <positive_integer>] [-vlan <positive_integer>] [-interface <interface_name>] [-priority <positive_integer>] [-msr ( ENABLED | DISABLED ) [-monitor <string>]] [-state ( ENABLED | DISABLED )]
- show ns pbr
Example:
> add ns pbr pbr1 allow -srcip 10.102.37.252 -destip 10.10.10.2 -nexthop 10.102.29.77
Done
<!--NeedCopy-->
To modify the priority of a PBR by using the CLI:
At the command prompt, type the following commands to modify the priority and verify the configuration:
- set ns pbr <name> [-action ( ALLOW | DENY )] [-srcIP [<operator>] <srcIPVal>] [-srcPort [<operator>] <srcPortVal>] [-destIP [<operator>] <destIPVal>] [-destPort [<operator>] <destPortVal>] [-nextHop <nextHopVal>] [-srcMac <mac_addr>] [-protocol <protocol> | -protocolNumber <positive_integer>] [-vlan <positive_integer>] [-interface <interface_name>] [-priority <positive_integer>] [-msr ( ENABLED | DISABLED ) [-monitor <string>]] [-state ( ENABLED | DISABLED )]
- show ns pbr [<name>]
Example:
> set ns pbr pbr1 -priority 23
Done
<!--NeedCopy-->
To remove one or all PBRs by using the CLI:
At the command prompt, type one of the following commands:
- rm ns pbr <name>
- clear ns pbrs
Example:
> rm ns pbr pbr1
Done
> clear ns PBRs
Done
<!--NeedCopy-->
GUI procedures
To create a PBR by using the GUI:
Navigate to System > Network > PBRs, on the PBRs tab, add a new PBR, or edit an existing PBR.
To remove one or all PBRs by using the GUI:
Navigate to System > Network > PBRs, on the PBRs tab, delete the PBR.
Applying a PBR
You must apply a PBR to activate it. The following procedure reapplies all PBRs that you have not disabled. The PBRs constitute a memory tree (lookup table). For example, if you create 10 PBRs (p1 - p10), and then you create another PBR (p11) and apply it, all of the PBRs (p1 - p11) are freshly applied and a new lookup table is created. If a session has a DENY PBR related to it, the session is destroyed.
You must apply this procedure after every modification you make to any PBR. For example, you must follow this procedure after disabling a PBR.
Note: PBRs created on the Citrix ADC appliance do not work until they are applied.
To apply a PBR by using the CLI:
At the command prompt, type:
apply ns PBRs
To apply a PBR by using the GUI:
- Navigate to System > Network > PBRs.
- On the PBRs tab, select the PBR, in the Action list, select Apply.
Enabling or Disabling PBRs
By default, the PBRs are enabled. This means that when PBRs are applied, the Citrix ADC appliance automatically compares incoming packets against the configured PBRs. If a PBR is not required in the lookup table, but it needs to be retained in the configuration, it must be disabled before the PBRs are applied. After the PBRs are applied, the Citrix ADC does not compare incoming packets against disabled PBRs.
To enable or disable a PBR by using the CLI:
At the command prompt, type one of the following commands:
- enable ns pbr <name>
- disable ns pbr <name>
Example:
> enable ns PBR pbr1
Done
> show ns PBR pbr1
1) Name: pbr1
Action: ALLOW Hits: 0
srcIP = 10.102.37.252
destIP = 10.10.10.2
srcMac: Protocol:
Vlan: Interface:
Active Status: ENABLED Applied Status: APPLIED
Priority: 10
NextHop: 10.102.29.77
Done
> disable ns PBR pbr1
Warning: PBR modified, use 'apply pbrs' to commit this operation
> apply pbrs
Done
> show ns PBR pbr1
1) Name: pbr1
Action: ALLOW Hits: 0
srcIP = 10.102.37.252
destIP = 10.10.10.2
srcMac: Protocol:
Vlan: Interface:
Active Status: DISABLED Applied Status: NOTAPPLIED
Priority: 10
NextHop: 10.102.29.77
Done
<!--NeedCopy-->
To enable or disable a PBR by using the GUI:
- Navigate to System > Network > PBRs.
- On the PBRs tab, select the PBR, in the Action list, select Enable or Disable.
Renumbering PBRs
You can automatically renumber the PBRs to set their priorities to multiples of 10.
To renumber PBRs by using the CLI:
At the command prompt, type:
- renumber ns pbrs
To renumber PBRs by using the GUI:
Navigate to System > Network > PBRs, on the PBRs tab, in the Action list, select Renumber Priority (s).
Use Case - PBR with Multiple Hops
Consider a scenario in which two PBRs, PBR1 and PBR2, are configured on Citrix ADC appliance NS1. PBR1 routes all the outgoing packets, with source IP address as 10.102.29.30, to next hop router R1. PBR2 routes all the outgoing packets, with source IP address as 10.102.29.90, to next hop router R2. R3 is another next hop router connected to NS1.
If router R1 fails, all the outgoing packets that matched against PBR1 are dropped. To avoid this situation, you can specify a link load balancing (LLB) virtual server in the next hop field while creating or modifying a PBR. Multiple next hops are bound to the LLB virtual server as services (for example R1, R2, and R3). Now, if R1 fails, all the packets that matched against PBR1 are routed to R2 or R3 as determined by the LB method configured on the LLB virtual server.
The Citrix ADC appliance throws an error if you attempt to create a PBR with an LLB virtual server as the next hop in the following cases:
- Adding another PBR with the same LLB virtual server.
- Specifying a nonexistent LLB virtual server.
- Specifying an LLB virtual server for which the bound services are not next hops.
- Specifying an LLB virtual server for which the LB method is not set to one of the following:
- ROUNDROBIN
- DESTINATIONIPHASH
- SOURCEIPHASH
- SRCIPDESTIPHASH
- LEASTPACKETS
- LEASTBANDWIDTH
- LTRM
- CALLIDHASH
- CUSTOM LOAD
- Specifying an LLB virtual server for which the LB persistence type is not set to one of the following:
- DESTIP
- SOURCEIP
- SRCDSTIP
The following table lists the names and values of the entities configured on the Citrix ADC appliance:
Entity Type | Name | IP Address |
---|---|---|
Link load balancing virtual server | LLB1 | NA |
Services (next hops) | Router1 | 1.1.1.254 |
Router2 | 2.2.2.254 | |
Router3 | 3.3.3.254 | |
PBRs | PBR1 | NA |
PBR2 | NA |
Table 1. Sample Values for Creating Entities
To implement the configuration described above, you need to:
- Create services Router1, Router2, and Router3 that represent next hop routers R1, R2, and R3.
- Create link load balancing virtual server LLB1 and bind services Router1, Router2, and Router3 to it.
- Create PBRs PBR1 and PBR2, with next hop fields set as LLB1 and 2.2.2.254 (IP address of the router R2), respectively.
To create a service by using the CLI:
At the command prompt, type:
- add service <name> <IP> <serviceType> <port>
- show service <name>
Example:
> add service Router1 1.1.1.254 ANY *
Done
> add service Router2 2.2.2.254 ANY *
Done
> add service Router3 3.3.3.254 ANY *
Done
<!--NeedCopy-->
To create a service by using the GUI:
Navigate to Traffic Management > Load Balancing > Services, and create a service.
To create a link load balancing virtual server and bind a service by using the CLI:
At the command prompt, type:
- add lb vserver <name> <serviceType>
- bind lb vserver < name> <serviceName>
- show lb vserver < name>
Example:
> add lb vserver LLB1 ANY
Done
> bind lb vserver LLB1 Router1 Router2 Router3
Done
<!--NeedCopy-->
To create a link load balancing virtual server and bind a service by using the GUI:
- Navigate to Traffic Management > Load Balancing > Virtual Servers, and create a virtual server for link load balancing. Specify ANY in the Protocol field. Note: Make sure that Directly Addressable is unchecked.
- Under the Services tab, in the Active column, select the check box for the service that you want to bind to the virtual server.
To create a PBR by using the CLI:
At the command prompt, type:
- add ns pbr <name> <action> [-srcIP [<operator>] <srcIPVal>] [-nextHop <nextHopVal>]
- show ns pbr
Example:
> add pbr PBR1 ALLOW -srcIP 10.102.29.30 -nextHop LLB1
Done
> add pbr PBR2 ALLOW -srcIP 10.102.29.90 -nextHop 2.2.2.254
Done
<!--NeedCopy-->
To create a PBR by using the GUI:
Navigate to System > Network > PBRs, on the PBRs tab, add a new PBR.