Skip to content
Ask AI

Routing Policy

Table 1 IP Prefix List View

CommandPurpose
**show ip prefix-list ** [summary|detail|list_name]Display IP prefix list configuration.

[Command] **show ip prefix-list ** [summary|detail|list_name]

[Purpose] Display IP prefix list configuration.

[Parameters]

ParameterDescription
list_nameSpecify the name of IP prefix list.

[View] Privileged User View

[Use Cases]

sonic# show ip prefix-list list1
ZEBRA: ip prefix-list list1: 2 entries
seq 3 permit 10.0.0.0/24 ge 25 le 26
seq 4 permit 20.0.0.0/24 ge 25 le 26
OSPF: ip prefix-list list1: 2 entries
seq 3 permit 10.0.0.0/24 ge 25 le 26
seq 4 permit 20.0.0.0/24 ge 25 le 26
BGP: ip prefix-list list1: 2 entries
seq 3 permit 10.0.0.0/24 ge 25 le 26
seq 4 permit 20.0.0.0/24 ge 25 le 26
ISIS: ip prefix-list list1: 2 entries
seq 3 permit 10.0.0.0/24 ge 25 le 26
seq 4 permit 20.0.0.0/24 ge 25 le 26

Table 2 IP Prefix List Config

CommandPurpose
ip prefix-list list_name [seq sequence_number] {permit|deny} {any|A.B.C.D/M [ge ge|le le]}Add an IP prefix list.

[Command] ip prefix-list list_name [seq sequence_number] {permit|deny} {any|A.B.C.D/M [ge ge|le le]}

[Purpose] Add an IP prefix list for reference by ROUTE-MAP.

[Parameters]

ParameterDescription
list_nameSpecify the name of IP prefix list.
sequence_numberSpecify the sequence number.
A.B.C.D/MSpecifiy the network segment that this table entry matches.
geSpecify the minimum prefix length, and the range is from 0 to 32.
leSpecify the maximum prefix length, and the range is from 0 to 32.

[View] Global Configuration View

[Notes] The relationship between le, ge and length is: length <= ge <= le; Configuration of logically conflicting table entries within the same prefix list is not allowed. The list_name and sequence_number uniquely identify a table entry, and the IP prefix is not allowed to be the same between different table entries. Run command no ip prefix-list list_name [seq sequence_number] {permit|deny} {any|A.B.C.D/M [ge ge|le le]} to delete IP prefix list.

[Use Cases]

sonic# configure terminal
sonic(config)# ip prefix-list list1 seq 3 permit 10.0.0.0/24 le 26 ge 25

Table 3 Route-Map View

CommandPurpose
**show route-map ** [route-map|json]Display route map.

[Command] **show route-map ** [route-map|json]

[Purpose] Display route map.

[Parameters]

ParameterDescription
route-mapRoute map name.

[View] Privileged User View

[Use Cases]

sonic# show route-map
ZEBRA:
route-map: test Invoked: 0 Optimization: enabled Processed Change: false
permit, sequence 10 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
permit, sequence 1000 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
OSPF:
route-map: test Invoked: 0 Optimization: enabled Processed Change: false
permit, sequence 10 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
permit, sequence 1000 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
OSPF6:
route-map: test Invoked: 0 Optimization: enabled Processed Change: false
permit, sequence 10 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
permit, sequence 1000 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
BGP:
route-map: test Invoked: 0 Optimization: enabled Processed Change: false
permit, sequence 10 Invoked 0
Match clauses:
Set clauses:
as-path exclude 1 31
comm-list 1
Call clause:
Action:
Exit routemap
permit, sequence 1000 Invoked 0
Match clauses:
community 10
Set clauses:
as-path prepend 1 1
Call clause:
Action:
Exit routemap
ISIS:
route-map: test Invoked: 0 Optimization: enabled Processed Change: false
permit, sequence 10 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap
permit, sequence 1000 Invoked 0
Match clauses:
Set clauses:
Call clause:
Action:
Exit routemap

Table 4 Route-Map Config

CommandPurpose
route-map route-map {permit|deny} seq-numCreate a route map and enter Route-map Configuration View.
description descriptionSpecify the description for the route-map.
matchas-path as_path_filter_nameMatch AS-path list.
match community {community_list_number|community_list_name} [exact-match]Match BGP community list.
match extcommunity {extcommunity_list_number|extcommunity_list_name}Match BGP/VPN extended community list.
match {ip|ipv6} address {prefix-len length|prefix-list list_name}Match address of route.
match {ip|ipv6} next-hop {prefix-len length|prefix-list list_name|address{A.B.C.D|X:X::X:X}|type blackhole}Match next-hop address of route.
match local-preference preference_valueMatch local-preference of route.
match metric metric_valueMatch metric of route.
match peer{A.B.C.D|X:X::X:X|interface_name}Match peer address.
set as-path prepend {as-path|last-as number}Prepend to the as-path.
set as-path exclude AS-numberExclude from the as-path.
setcommunity AA:NNSet BGP Community.
set community noneSet no BGP Community.
set distance distanceSet BGP Administrative Distance to use.
set extcommunitynoneSet no extended community attribute.
set extcommunity rt ASN:NN_OR_IP-ADDRESS:NNSet Route Target extended community.
set extcommunity soo ASN:NN_OR_IP-ADDRESS:NNSet Site-of-Origin extended community.
setip next-hop {A.B.C.D|peer-address}Set next-hop IP address.
set ipv6 next-hop {local X:X::X:X|global X:X::X:X|peer-address}Set next-hop IPv6 address.
set local-preference preference_valueSet local-preference of route.
set metric {metric_value|rtt|+rtt|-rtt}Set metric value.
set weight weightSet BGP weight for routing table.

[Command] route-map route-map {permit|deny} seq-num

[Purpose] Create a route map and enter Route-map Configuration View.

[Parameters]

ParameterDescription
route-mapRoute map name.
seq-numSequence number, the range is from 1 to 65535.

[View] Global Configuration View

[Notes] Run command no route-map route-map {permit|deny} seq_num to delete the route map.

[Use Cases]

sonic(config)# route-map test permit 100
sonic(config-route-map)#

[Command] description description

[Purpose] Specify the description for the route-map.

[Parameters]

ParameterDescription
descriptionIn string form.

[View] Route-map Configuration View

[Notes] Run command no description description to delete description.

[Use Cases]

sonic# configure terminal
sonic(config)# route-map test permit 1000
sonic(config)# description test

[Command] match as-path as_path_filter_name

[Purpose] Match AS-path list.

[Parameters]

ParameterDescription
as_path_filter_nameAS-path list.

[View] Route-map Configuration View

[Notes] Run command no match as-path as_path_filter_name to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match as-path test

[Command] match community {community_list_number|community_list_name} [exact-match]

[Purpose] Match BGP community list.

[Parameters]

ParameterDescription
community_list_numberCommunity-list number, range from 1 to 500. 1-99 as standard and 100-500 as expanded.
community_list_nameCommunity name.
exact-matchExact match.

[View] Route-map Configuration View

[Notes] Run command no match community {community_list_number|community_list_name} [exact-match] to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match community test

[Command] matchextcommunity {extcommunity_list_number|extcommunity_list_name}

[Purpose] Match BGP/VPN extended community list.

[Parameters]

ParameterDescription
extcommunity_list_numberCommunity-list number, range from 1 to 500. 1-99 as standard and 100-500 as expanded.
extcommunity_list_nameSpecify extcommunity-list.

[View] Route-map Configuration View

[Notes] Run command nomatch extcommunity {extcommunity_list_number|extcommunity_list_name} to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match extcommunity 100

[Command] match {ip|ipv6} address {prefix-len length|prefix-list list_name}

[Purpose] Match address of route.

[Parameters]

ParameterDescription
lengthIP address length.
list_nameSpecify the name of IP prefix list.

[View] Route-map Configuration View

[Notes] Run command no match {ip|ipv6} address {prefix-len length|prefix-list list_name} to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match ip address prefix-list test

[Command] match {ip|ipv6} next-hop {prefix-len length|prefix-list list_name|address {A.B.C.D|X:X::X:X}|type blackhole}

[Purpose] Match next-hop address of route.

[Parameters]

ParameterDescription
lengthIP address length.
list_nameSpecify the name of IP prefix list.
A.B.C.DIPv4 address.
X:X::X:XIPv6 address.

[View] Route-map Configuration View

[Notes] Run command no match {ip|ipv6} next-hop {prefix-len length|prefix-list list_name|address {A.B.C.D|X:X::X:X}|typeblackhole} to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match ip next-hop type blackhole

[Command] match local-preference preference_value

[Purpose] Match local-preference of route.

[Parameters]

ParameterDescription
preference_valueRoute preference, range from 0 to 4294967295.

[View] Route-map Configuration View

[Notes] Run command nomatch local-preference preference_value to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match local-preference 12

[Command] match metric metric_value

[Purpose] Match metric of route.

[Parameters]

ParameterDescription
metric_valueRoute metric, range from 0 to 4294967295.

[View] Route-map Configuration View

[Notes] Run command no match metric metric_value to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match metric 12

[Command] match peer {A.B.C.D|X:X::X:X|interface_name}

[Purpose] Match peer address.

[Parameters]

ParameterDescription
A.B.C.DIPv4 address
X:X::X:XIPv6 address
interface_nameinterface name

[View] Route-map Configuration View

[Notes] Run command no match peer {A.B.C.D|X:X::X:X|interface_name} to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# match peer 1.1.1.1

[Command] set as-path prepend {as-path|last-as number}

[Purpose] Prepend to the as-path.

[Parameters]

ParameterDescription
as-pathAS number, range from 1 to 4294967295. Specify multiple AS numbers separated by spaces.
last-as numberUse the last AS-number in the as-path. The number range is 1~10.

[View] Route-map Configuration View

[Notes] set as-path prepend {as-path|last-as number} to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set as-path prepend 100 200

[Command] set as-path exclude AS-number

[Purpose] Exclude from the as-path.

[Parameters]

ParameterDescription
AS-numberAS number, range from 1 to 4294967295. Specify multiple AS numbers separated by spaces.

[View] Route-map Configuration View

[Notes] Run command no set as-path exclude AS-number to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set as-path exclude 12

[Command] set community AA:NN

[Purpose] Set BGP Community.

[Parameters]

ParameterDescription
AA:NNCommunity number in AA:NN format (where AA and NN are (0-65535)) or local-AS|no-advertise|no-export|internet|graceful-shutdown|accept-own-nexthop|accept-own|route-filter-translated-v4|route-filter-v4|route-filter-translated-v6|route-filter-v6|llgr-stale|no-llgr|blackhole|no-peer or additive

[View] Route-map Configuration View

[Notes] Run command no set community AA:NN to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set community 12

[Command] set communitynone

[Purpose] Set no BGP Community.

[View] Route-map Configuration View

[Notes] Run command no set community to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set community none

[Command] set distance distance

[Purpose] Set BGP Administrative Distance to use.

[Parameters]

ParameterDescription
distanceRange from 0 to 255.

[View] Route-map Configuration View

[Notes] Run command no set distance distance to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set distance 12

[Command] set extcommunitynone

[Purpose] Set no extended community attribute.

[View] Route-map Configuration View

[Notes] Run command no set extcommunity to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set extcommunity none

[Command] set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN

[Purpose] Set Route Target extended community.

[Parameters]

ParameterDescription
ASN:NN_OR_IP-ADDRESS:NNVPN extended community. When specifying more than one, separate them with a space.

[View] Route-map Configuration View

[Notes] Run command no set extcommunity rt ASN:NN_OR_IP-ADDRESS:NN to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set extcommunity rt 100:1:2

[Command] set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN

[Purpose] Set Site-of-Origin extended community.

[Parameters]

ParameterDescription
ASN:NN_OR_IP-ADDRESS:NNVPN extended community. When specifying more than one, separate them with a space.

[View] Route-map Configuration View

[Notes] Run command no set extcommunity soo ASN:NN_OR_IP-ADDRESS:NN to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set extcommunity soo 100:1:2

[Command] set ip next-hop {A.B.C.D|peer-address}

[Purpose] Set next-hop IP address.

[Parameters]

ParameterDescription
A.B.C.DIPv4 address.
peer-addressUse peer address (for BGP only)

[View] Route-map Configuration View

[Notes] Run command no set ip next-hop A.B.C.D to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set ip next-hop 1.1.1.1

[Command] set ipv6 next-hop {local X:X::X:X|global X:X::X:X|peer-address}

[Purpose] Set next-hop IPv6 address.

[Parameters]

ParameterDescription
local X:X::X:XIPv6 local address.
global X:X::X:XIPv6 global address.
peer-addressUse peer address (for BGP only)

[View] Route-map Configuration View

[Notes] Run command no set ipv6 next-hop local X:X::X:X to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set ipv6 next-hop local 100::1

[Command] set local-preference preference_value

[Purpose] Set local-preference of route.

[Parameters]

ParameterDescription
preference_valuePreference value (0-4294967295)

[View] Route-map Configuration View

[Notes] Run command no set local-preference preference_value to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set local-preference 12

[Command] set metric {metric_value|rtt|+rtt|-rtt}

[Purpose] Set metric value.

[Parameters]

ParameterDescription
metric_valueMetric value (use +/- for additions or subtractions) (-4294967295-4294967295).
rttAssign round trip time.
+rttAdd round trip time.
-rttSubtract round trip time.

[View] Route-map Configuration View

[Notes] Run command no set metric {metric_value|rtt|+rtt|-rtt } to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set metric 12

[Command] set weight weight

[Purpose] Set BGP weight for routing table.

[Parameters]

ParameterDescription
weightWeight value, range from 0 to 4294967295.

[View] Route-map Configuration View

[Notes] Run command no set weight weight to delete the configuration.

[Use Cases]

sonic(config)# route-map test permit 1000
sonic(config-route-map)# set weight 12