Configuration Guide
Policy-Based Routing Configuration Guide
7 min
introduction introduction policy based routing (pbr) is a routing mechanism that forwards packets based on custom defined policies when packets are routed, they can be matched based on source ip address, destination ip address, ip protocol, source tcp/udp port number, and destination tcp/udp port number for packets that meet the matching conditions, the next hop is set to complete the forwarding control of the packets policy based routing configuration policy based routing configuration configure policy based routing configure policy based routing table 1 configure policy based routing table 1 configure policy based routing purpose commands description enter global configuration view configure terminal create a pbr policy and enter the pbr map configuration view pbr map pbr map name seq seq num sequence number, with a value range of 1 to 700 configure pbr policy matching fields match { dst ip dip | dst port dport | ip protocol { tcp | udp }| src ip sip | src port sport } configure pbr policy actions set { nexthop { a b c d | x\ x x x }| nexthop group next group name } create a next hop group and enter the next hop group configuration view nexthop group next group name configure the next hop nexthop { a b c d | x\ x x x } configure interface binding with policy routing configure interface binding with policy routing table 2 configure interface binding with policy routing table 2 configure interface binding with policy routing purpose commands description enter global configuration view configure terminal enter interface configuration view interface interface type interface name interface type optional ethernet, link aggregation bind pbr policy pbr policy pbr map name pbr map name pbr policy name display and maintenance display and maintenance table 3 pbr display and maintenance table 3 pbr display and maintenance purpose command description check pbr binding information show pbr interface \[ ethernet interface name | link aggregation lag id ] \[ json ] check pbr policy information show pbr map \[ pbr map name | json | detail ] check pbr next hop information show pbr nexthop groups \[ next group name | json ] typical configuration example typical configuration example networking requirements to achieve flexible scheduling and refined management of traffic, policy routing (pbr) technology needs to be deployed in the network architecture we now require vm1 to serve as the traffic source, release two streams of traffic externally, configure pbr through the switch, and forward one stream to vm2 and the other stream to vm3 to meet the traffic processing needs in different business scenarios, improve network resource utilization efficiency and business flexibility topology procedure \#configure interface ip sonic# config terminal sonic(config)# interface ethernet 0/72 sonic(config if 0/72)# ip address 72 0 0 1/24 sonic(config if 0/72)# exit sonic(config)# interface ethernet 0/73 sonic(config if 0/73)# ip address 73 0 0 1/24 sonic(config if 0/73)# exit sonic(config)# interface ethernet 0/74 sonic(config if 0/74)# ip address 74 0 0 1/24 sonic(config if 0/74)# exit \#configure pbr sonic# config terminal sonic(config)# pbr map test seq 1 sonic(config pbr map)# match src ip 1 0 0 0/24 sonic(config pbr map)# set nexthop 73 0 0 2 sonic(config pbr map)# exit sonic(config)# pbr map test seq 2 sonic(config pbr map)# match src ip 2 0 0 0/24 sonic(config pbr map)# set nexthop 74 0 0 2 sonic(config pbr map)# exit sonic(config)# interface ethernet 0/72 sonic(config if 0/72)# pbr policy test sonic(config if 0/72)# exit verify the configuration \#check pbr configuration sonic# show pbr interface ethernet 0/72(106) with pbr policy test leaf 129# show pbr nexthop groups nexthop group test2 table 10001 valid 0 installed 0 valid 0 nexthop 74 0 0 2 nexthop group test1 table 10000 valid 0 installed 0 valid 0 nexthop 73 0 0 2 leaf 129# show pbr map pbr map test valid no seq 1 rule 300 installed no reason invalid nh src match 1 0 0 0/24 nexthop 73 0 0 2 installed no tableid 10000 seq 2 rule 301 installed no reason invalid nh src match 2 0 0 0/24 nexthop 74 0 0 2 installed no tableid 10001 tc2 is configured with host1 ip 73 0 0 2, gateway ip 73 0 0 1 tc3 is configured with host2 ip 74 0 0 2, gateway ip 74 0 0 1 tc1 sends two streams with source ips 1 0 0 1 and 2 0 0 1, tc2 can capture the stream with source ip 1 0 0 1, and tc3 can capture the stream with source ip 2 0 0 1
