跳转到内容
Ask AI

Basic Routing

此内容尚不支持你的语言。

Table 1 Route View

CommandPurpose
show{ip|ipv6}route[summary|connected|static|bgp|ospf|isis|ip-address]Display IPv4/IPv6 route info.
show{ip|ipv6}protocolDisplay IPv4/IPv6 protocol info.
show pbr interface[ethernet interface_name|link-aggregation lag-id] [json]Display PBR binding info.
show pbr map[pbr-map-name|json|detail]Display PBR policy info.
show pbr nexthop-groups[next-group-name|json]Display PBR next-hop info.

show {ip|ipv6} route [summary|connected|static|bgp|ospf|isis|ip-address ]

Section titled “show {ip|ipv6} route [summary|connected|static|bgp|ospf|isis|ip-address ]”

[Command]

show{ip|ipv6}route [summary|connected|static|bgp|ospf|isis|ip-address]

[Purpose]

Display IPv4/IPv6 route info.

[Parameters]

ParameterDescription
ip-addressIPv4 or IPv6 address.

[View]

Privileged User View

[Use Cases]

sonic# show ip route connected
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
F - PBR, f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
C>* 10.0.0.0/24 is directly connected, Ethernet112, 00:22:20
C>* 10.1.0.103/32 is directly connected, Loopback0, 20:16:20
C>* 10.250.0.0/24 is directly connected, eth0, 20:16:40
C>* 11.11.10.0/24 is directly connected, Vlan10, 20:16:10
C>* 112.0.0.0/24 is directly connected, Ethernet112, 00:22:20
C>* 122.0.0.0/24 is directly connected, Vlan100, 20:16:10

[Command]

show{ip|ipv6}protocol

[Purpose]

Display IPv4/IPv6 protocol info.

[View]

Privileged User View

[Use Cases]

sonic# show ip protocol
Protocol : route-map
------------------------
system : none
kernel : none
connected : none
static : none
rip : none
ripng : none
ospf : none
ospf6 : none
isis : none
bgp : RM_SET_SRC
pim : none
eigrp : none
nhrp : none
hsls : none
olsr : none
table : none
ldp : none
vnc : none
vnc-direct : none
vnc-rn : none
bgp-direct : none
bgp-direct-to-nve-groups : none
babel : none
sharp : none
pbr : none
bfd : none
wildcard : none
any : none
Section titled “show pbr interface [ethernet interface_name|link-aggregation lag-id] [json]”

[Command]

show pbr interface [ethernet interface_name|link-aggregation lag-id] [json]

[Purpose]

Display PBR binding info.

[Parameters]

ParameterDescription
interface_nameInterface name(eg.0/1)
lag-idLAG ID, the range is from 1 to 9999.

[View]

Privileged User View

[Use Cases]

sonic# show pbr interface ethernet 0/0
ethernet 0/0(15) with pbr-policy yd1

[Command]

show pbr map[pbr-map-name|json|detail]

[Purpose]

Display PBR policy info.

[Parameters]

ParameterDescription
pbr-map-namePBR map name.

[View]

Privileged User View

[Use Cases]

sonic# show pbr map yd1
pbr-map yd1 valid: yes
Seq: 1 rule: 300
Installed: yes Reason: Valid
SRC Match: 100.0.0.2/32
nexthop 102.0.0.2
Installed: yes Tableid: 10002

show pbr nexthop-groups [next-group-name|json]

Section titled “show pbr nexthop-groups [next-group-name|json]”

[Command]

show pbr nexthop-groups[next-group-name|json]

[Purpose]

Display PBR next-hop info.

[Parameters]

ParameterDescription
next-group-nameNext-hop group name.

[View]

Privileged User View

[Use Cases]

sonic# show pbr nexthop-groups yd
Nexthop-Group: yd Table: 10000 Valid: 1 Installed: 1
Valid: 1 nexthop 102.0.0.2
Valid: 1 nexthop 103.0.0.2

Table 2 Route Config

CommandPurpose
ip route A.B.C.D/M {A.B.C.D|interface-type interface-name}[distance][description description] [track track-id] [bfd] [nexthop-vrf vrf]Configure IPv4 static routes.
ipv6 route X:X::X:X/M {X:X::X:X|interface-type interface-name}[distance][description description] [track track-id] [bfd] [nexthop-vrf vrf]Configure IPv6 static routes.
pbr-map pbr-map-name seq seq-numCreate PBR policy and enter the PBR-map configuration view.
match {dst-ip dip|dst-port dport|ip-protocol ip-protocol|src-ip sip|src-port sport}Configure PBR policy match fields.
set {nexthop {A.B.C.D|X:X::X:X}|nexthop-group next-group-name}Configure PBR policy actions.
nexthop-group next-group-nameCreate a next-hop group and enter the next-hop group configuration mode.
nexthop {A.B.C.D|X:X::X:X}Configure the next hop.
pbr-policy pbr-map-nameBind PBR policy.

ip route A.B.C.D/M {A.B.C.D|interface-type interface-name} [OPTIONs]

Section titled “ip route A.B.C.D/M {A.B.C.D|interface-type interface-name} [OPTIONs]”

[Command]

ip route A.B.C.D/M {A.B.C.D|interface-type interface-name}[distance][description description] [track track-id] [bfd] [nexthop-vrf vrf]

[Purpose]

Configure IPv4 static routes.

[Parameters]

ParameterDescription
A.B.C.D/MSpecify the destination network segment for routing.
A.B.C.DSpecify the IP address of next hop of the route.
interface-typeThe next-hop interface type. Optional parameters include ethernet, vlan, and link-aggregation.
interface-nameNext-hop interface name.
distanceStatic route distance value,range from 1-255. Default value: 1.
descriptionSpecify the description for the route. In string form.
track_idTrack ID, range from [1,4294967295].
bfdConfigure static route and BFD linkage.
vrfName of the VRF where the next-hop interface resides.

[View]

Global Configuration View / VRF Configuration View

[Notes]

Run command no ip route A.B.C.D/M {A.B.C.D|interface-type interface-name}[distance][description description] [track track-id] [bfd] [nexthop-vrf vrf] to delete static routes configuration.

[Use Cases]

sonic# configure terminal
sonic(config)# ip route 20.0.0.0/24 10.0.0.57 description test

ipv6 route X:X::X:X/M {X:X::X:X|interface-type interface-name} [OPTIONs]

Section titled “ipv6 route X:X::X:X/M {X:X::X:X|interface-type interface-name} [OPTIONs]”

[Command]

ipv6 route X:X::X:X/M {X:X::X:X|interface-type interface-name}[distance][description description] [track track-id] [bfd] [nexthop-vrf vrf]

[Purpose]

Configure IPv6 static routes.

[Parameters]

ParameterDescription
X:X::X:X/MSpecify the destination network segment for routing.
X:X::X:XSpecify the IP address of next hop of the route.
interface-typeThe next-hop interface type. Optional parameters include ethernet, vlan, and link-aggregation.
interface-nameNext-hop interface name.
distanceStatic route distance value,range from 1-255. Default value: 1.
descriptionSpecify the description for the route. In string form.
track_idTrack ID, range from [1,4294967295].
bfdConfigure static route and BFD linkage.
vrfName of the VRF where the next-hop interface resides.

[View]

Global Configuration View / VRF Configuration View

[Notes]

Run command no ipv6 route X:X::X:X/M {X:X::X:X|interface-type interface-name}[distance][description description] [track track-id] [bfd] [nexthop-vrf vrf] to delete static routes configuration.

[Use Cases]

sonic# configure terminal
sonic(config)# ipv6 route 2001::2/96 2002::1 track 1

[Command]

pbr-map pbr-map-name seq seq-num

[Purpose]

Create PBR policy and enter the PBR-map configuration view.

[Parameters]

ParameterDescription
pbr-map-namePBR map name.
seq-numSequence number, range from 1 to 700.

[View]

Global Configuration View

[Notes]

Run command no pbr-map pbr-map-name [seq seq_num] to delete PBR policy configuration.

[Use Cases]

sonic(config)# pbr-map pbrmap1 seq 1
sonic(config-pbr-map)#

match { dst-ip dip|dst-port dport|ip-protocol ip-protocol|src-ip sip|src-port sport}

Section titled “match { dst-ip dip|dst-port dport|ip-protocol ip-protocol|src-ip sip|src-port sport}”

[Command]

match {dst-ip dip|dst-port dport|ip-protocol ip-protocol|src-ip sip|src-port sport}

[Purpose]

Configure PBR policy match fields.

[Parameters]

ParameterDescription
dipDestination IP, A.B.C.D/M or X:X::X:X/M.
dst-portDestination port number, range from 1 to 65535.
ip-protocolTCP/UDP.
sipSource IP, A.B.C.D/M or X:X::X:X/M.
sportSource port number, range from 1 to 65535.

[View]

PBR-map Configuration View

[Notes]

Run command no match {dst-ip dip|dst-port dport|ip-protocol ip-protocol|src-ip sip|src-port sport} to delete PBR policy match fields.

[Use Cases]

sonic(config)# pbr-map pbrmap1 seq 1
sonic(config-pbr-map)# match src-ip 1.2.1.1/32
sonic(config-pbr-map)#

set {nexthop {A.B.C.D|X:X::X:X}|nexthop-group next-group-name}

Section titled “set {nexthop {A.B.C.D|X:X::X:X}|nexthop-group next-group-name}”

[Command]

set {nexthop {A.B.C.D|X:X::X:X}|nexthop-group next-group-name}

[Purpose]

Configure PBR policy actions.

[Parameters]

ParameterDescription
A.B.C.D|X:X::X:XNext hop IP.
next-group-nameNexthop-group name.

[View]

PBR-map Configuration View

[Notes]

Run command no set {nexthop {A.B.C.D|X:X::X:X}|nexthop-group next-group-name} to delete PBR policy actions.

[Use Cases]

sonic(config)# pbr-map pbrmap1 seq 1
sonic(config-pbr-map)# set nexthop 83.0.0.1
sonic(config-pbr-map)#

[Command]

nexthop-group next-group-name

[Purpose]

Create a next-hop group and enter the next-hop group configuration mode.

[Parameters]

ParameterDescription
next-group-nameNexthop-group name.

[View]

Global Configuration View

[Notes]

Run command no nexthop-group next-group-name to delete the next-hop group configuration.

[Use Cases]

sonic(config)# nexthop-group nextgroup1
sonic(config-nh-group)#

[Command]

nexthop {A.B.C.D|X:X::X:X}

[Purpose]

Configure the next hop.

[Parameters]

ParameterDescription
A.B.C.D|X:X::X:XNext hop IP.

[View]

Nexthop-group Configuration View

[Notes]

Run command no nexthop {A.B.C.D|X:X::X:X} to delete the next hop configuration.

[Use Cases]

sonic(config)# nexthop-group nextgroup1
sonic(config-nh-group)# nexthop 82.0.0.1
sonic(config-nh-group)#

[Command]

pbr-policy pbr-map-name

[Purpose]

Bind PBR policy.

[Parameters]

ParameterDescription
pbr-map-namePBR map name.

[View]

Physical Interface/LAGIF Configuration View

[Notes]

Run command no pbr-policy pbr-map-name to delete binding PBR policy configuration.

[Use Cases]

sonic(config)# interface ethernet 0/0
sonic(config-if-0/0)# pbr-policy pbrmap1
sonic(config-if-0/0)#