Dell Networking SONiC IPv4 和 IPv6 静态路由

Résumé: 本文介绍如何在 Dell SONiC 管理框架 CLI 中配置静态路由。

Cet article concerne Cet article ne concerne pas Cet article n’est associé à aucun produit spécifique. Toutes les versions du produit ne sont pas identifiées dans cet article.

Instructions

文章的前提条件

本文使用运行 Dell SONiC 4.1 的交换机。我们在配置中使用标准接口命名。要了解有关 Dell SONiC 中各种接口命名模式的更多信息,请参阅戴尔文章 202172 Dell Networking S 系列:基本接口配置 - SONiC 4.0

 

指数

介绍
IPv4 静态路由 IPv6 静态路由  

简介

配置固定的静态路由,以确保路由流量可以与指定的目标设备交换。例如,如果动态路由不可用,则使用静态路由作为备份,或者在没有其他路由可用时访问网络网关。

静态路由的设计建议:
  • 确保同一 VRF 中没有重叠的静态路由
  • 对于路由流量,必须确保下一跳可访问性
 

IPv4 静态路由

配置语法:
 
admin@sonic:~$ sonic-cli
sonic# configure
sonic(config)# ip route [vrf vrf-name] dest-ip-prefix {next-hop-ip [interface interfacetype interface-number] | interface interface-type interface-number | blackhole} [nexthopvrf vrf-name] [tag tag-name] [track id] [dest-metric]

说明:
要配置静态 IPv4 路由,请输入目标地址前缀和以下可选值:
  • (可选)vrf vrf-name -输入要在其中配置静态路由的 VRF 实例的名称。对于管理 VRF,请使用管理。
  • dest-prefix -输入目标设备的 IPv4 前缀。以 A.B.C.D/mask 格式输入 IPv4 前缀,其中掩码是 IPv4 前缀掩码,从 1 到 32;例如,10.10.10.0/24。
  • (可选)下一跳 ip — 输入下一跳 IPv4 地址作为目标前缀的网关。
  • (可选)接口接口类型接口编号 -指定静态路由 IPv4 流量传递到目标的交换机接口,其中接口类型接口编号是以下值之一:
    • 接口 Eth 插槽/端口[/分解端口]
    • 接口 PortChannel 端口通道编号
    • 接口 Vlan vlan-id
    • 接口环回编号
    • 接口管理 0
  • (可选)黑孔 — 通过动态将流量路由到目标设备或数据收集设备,阻止来自可疑源或拒绝服务 (DoS) 攻击的流量。
    • (可选)nexthop-vrf vrf-name — 如果先前指定的 VRF 或接口位于不同的 VRF 中,则输入下一跳设备上使用的 VRF 实例的名称。对于管理 VRF,请使用管理。使用此参数可配置静态路由泄漏。
    • (可选)标记名称 — 输入要用于匹配路由映射中路由的标签编号,从 1 到 4294967295。
    • (可选)类别 ID — 输入一个 ID 编号,以跟踪用于评估服务级别协议 (SLA) 中性能的路由,从 1 到 255。
    • (可选)dest-metric — 输入确定路由路径优先级的数字,从 1 到 255 — 数字越低,路由优先级越高。静态路由默认值为 1。


IPv4 示例配置

admin@sonic:~$ sonic-cli 
sonic# configure
sonic(config)# ip route 6.6.6.6/32 5.5.5.1
sonic(config)# ip route 7.7.7.7/32 blackhole 100
sonic(config)# ip route 4.4.4.0/24 4.4.4.1 nexthop-vrf Vrf-GREEN 200
sonic(config)# ip route vrf Vrf-RED 3.3.3.0/24 10.0.0.2 nexthop-vrf Vrf-GREEN
sonic(config)# ip route vrf Vrf-RED 8.8.8.0/24 interface Eth1/4 nexthop-vrf Vrf-GREEN 36
 

验证 IPv4 静态路由 

使用命令 show ip route staticshow ip route 以在默认路由表中查看 IPv4 静态路由。

使用命令 show ip route vrf show ip route vrf static 在默认路由表中查看 IPv4 静态路由。
 
sonic# show ip route static
Codes:  K - kernel route, C - connected, S - static, B - BGP, O - OSPF
        > - selected route, * - FIB route, q - queued route, r - rejected route
       Destination        Gateway                                                                    Dist/Metric   Last Update
--------------------------------------------------------------------------------------------------------------------------------
 S>*   4.4.4.0/24         via 4.4.4.1                     Eth1/6(vrf Vrf-GREEN)                      200/0         00:54:46 ago
 S>*   6.6.6.6/32         via 5.5.5.1                     Eth1/5                                     1/0           01:09:10 ago
 S>*   7.7.7.7/32         Unreachable (blackhole)                                                    100/0         01:23:19 ago
sonic# show ip route vrf Vrf-RED
Codes:  K - kernel route, C - connected, S - static, B - BGP, O - OSPF
        > - selected route, * - FIB route, q - queued route, r - rejected route
       Destination        Gateway                                                                    Dist/Metric   Last Update
--------------------------------------------------------------------------------------------------------------------------------
 S>*   3.3.3.0/24         via 10.0.0.2                    Eth1/9(vrf Vrf-GREEN)                      1/0           00:00:17 ago
 S>*   8.8.8.0/24         Direct                          Eth1/4(vrf Vrf-GREEN)                      36/0          01:00:35 ago
 

IPv6 静态路由

配置语法:
 
admin@sonic:~$ sonic-cli
sonic# configure
sonic(config)# ipv6 route [vrf vrf-name] dest-ipv6-prefix {next-hop-ipv6 [interface interface-type interface-number] | interface interface-type interface-number | blackhole} [nexthop-vrf vrf-name] [tag tag-name] [track id] [dest-metric]

说明:
要配置静态 IPv6 路由,请输入目标地址前缀和以下可选值:
  • (可选)vrf vrf-name — 输入要在其中配置静态路由的 VRF 实例的名称。对于管理 VRF,请使用管理。
  • dest-prefix -输入目标设备的 IPv6 前缀。以 x:x:x/mask 格式输入 IPv6 前缀,其中 mask 是 IPv6 前缀掩码,从 1 到 128;例如,2001:db8:1234:0000:::/64。
  • (可选)下一跳 ip —输入下一跳 IPv6 地址作为目标前缀的网关。
  • (可选)接口接口类型接口编号 — 指定静态路由 IPv4 流量传递到目标的交换机接口,其中接口类型接口编号是以下值之一:
    • 接口 Eth 插槽/端口[/分解端口]
    • 接口 PortChannel 端口通道编号
    • 接口 Vlan vlan-id
    • 接口环回编号
    • 接口管理 0
  • (可选)黑孔 -通过动态将流量路由到目标设备或数据收集设备,阻止来自可疑源的流量或拒绝服务 (DoS) 攻击。
  • (可选)nexthop-vrf vrf-name -如果之前指定的 VRF 或接口位于不同的 VRF 中,请输入下一跳设备上使用的 VRF 实例的名称。对于管理 VRF,请使用管理。使用此参数可配置静态路由泄漏。
  • (可选)标记名称 — 输入要用于匹配路由映射中路由的标签编号,从 1 到 4294967295。
  • (可选)磁道 ID —输入 ID 号以跟踪用于评估服务级别协议 (SLA) 中的性能的路由,从 1 到 255。
  • (可选)dest-metric — 输入确定路由路径优先级的数字,从 1 到 255 — 数字越低,路由优先级越高。静态路由默认值为 1。
 

IPv6 示例配置

admin@sonic:~$ sonic-cli
sonic# configure
sonic(config)# ipv6 route 3030::3300/120 3030::3301 36
sonic(config)# ipv6 route 2001:db6::/32 interface Eth1/7 150
sonic(config)# ipv6 route 2006::/24 blackhole 200
sonic(config)# ipv6 route vrf Vrf-RED 1001::/24 interface Eth1/4 nexthop-vrf Vrf-GREEN 20
sonic(config)# ipv6 route vrf Vrf-RED 1002::/24 interface Eth1/2 nexthop-vrf Vrf-GREEN 50
 

验证 IPv6 静态路由 

使用命令 show ipv6 route staticshow ip route 以在默认路由表中查看 IPv6 静态路由。

使用命令 show ipv6 route vrf static 以在默认路由表中查看 IPv6 静态路由。
 sonic# show ipv6 route static
Codes:  K - kernel route, C - connected, S - static, B - BGP, O - OSPF
        > - selected route, * - FIB route, q - queued route, r - rejected route
       Destination                                 Gateway                                                                                          Dist/Metric   Last Update
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 S>*   2001:db6::/32                               Direct                                                 Eth1/7                                    150/0         00:01:07 ago
 S>*   2006::/24                                   Unreachable (blackhole)                                                                          200/0         00:19:06 ago
 S     3030::3300/120                              via 3030::3301                                                                                   36/0          00:08:52 ago
sonic# show ipv6 route vrf Vrf-RED static
Codes:  K - kernel route, C - connected, S - static, B - BGP, O - OSPF
        > - selected route, * - FIB route, q - queued route, r - rejected route
       Destination                                 Gateway                                                                                          Dist/Metric   Last Update
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 S>*   1001::/24                                   Direct                                                 Eth1/4(vrf Vrf-GREEN)                     20/0          00:14:44 ago
 S>    1002::/24                                   Direct                                                 Eth1/2(vrf Vrf-GREEN)                     50/0          00:14:30 ago

Produits concernés

Enterprise SONiC Distribution, PowerSwitch E3200-ON Series, Dell EMC Networking N3200-ON, PowerSwitch S5212F-ON, PowerSwitch S5224F-ON, PowerSwitch S5232F-ON, PowerSwitch S5248F-ON, PowerSwitch S5296F-ON, PowerSwitch Z9100-ON, PowerSwitch Z9264F-ON , PowerSwitch Z9332F-ON, PowerSwitch Z9432F-ON ...
Propriétés de l’article
Numéro d’article: 000218054
Type d’article: How To
Dernière modification: 25 Jun 2025
Version:  5
Trouvez des réponses à vos questions auprès d’autres utilisateurs Dell
Services de support
Vérifiez si votre appareil est couvert par les services de support.