PBR - Transport Layer port number

When applying Policy Based Routing (PBR), it is possible to use the transport layer port number as a parameter for routing. The port number can also be changed in specific packets using PBR.

For example, if you want to change the destination UDP port of a packet using PBR, you can do the following:

In this example, we want to use a Route-map to change the destination UDP port from 4001 to 4002. It also sets the next hop IP to a particular address.

First, match the traffic using an access list:

access-list 101 permit udp any host 192.168.1.1 eq 4001

Then, create a route map that matches the access list and set the new port:

route-map PORTCHANGE permit 10 match ip address 101 set ip next-hop verify-availability 10.10.10.1 1 track 1 set port 4002

Apply the route map to the incoming interface:

interface GigabitEthernet0/0 ip policy route-map PORTCHANGE

The result is that any packet destined to 192.168.1.1 with a UDP destination port of 4001 will have its next hop IP set to 10.10.10.1 for routing, and will have its UDP destination port changed to 4002.

This technique can be applied to both unicast and Multicast traffic.

Links:

https://forum.networklessons.com/t/udp-port-reflection/45300/2?u=lagapidis