agentleFS
nanxiaoyaonanxiaoyao/network-huawei-skills/static-route/SKILL.md

static-route

Skill2 starsChanged 3 months agoMITView on GitHub

This skill should be used when the user asks to configure or troubleshoot static routes on Huawei CloudEngine / S series switches. Covers IPv4/IPv6 static route, default route, route preference, recursive routing, BFD/NQA linkage for fast failover, floating static route, and permanent advertisement. Applicable platforms S1720/S2700/S5700/S6720 V200R011C10+ and CloudEngine 5800-9800 V200R022C00+.

The file

Files
SKILL.md

华为交换机静态路由配置技能 (static-route)

适用平台 S 系列 V200R011C10+ | CE 系列 V200R022C00+ 文档来源 华为产品文档 dc_cfg_static-route_*

静态路由是手工配置 适合小型网络与策略路由 大型网络配合动态路由作兜底

触发场景

  • 小型网络规划路由
  • 配置默认路由 出口
  • 浮动静态路由(多链路主备)
  • 静态路由 + BFD 实现毫秒级切换
  • 静态路由 + NQA 实现链路探测
  • 跨网段路由不通排查
  • IPv6 静态路由配置

静态路由优先级

路由类型默认优先级
Direct(直连)0
OSPF10
IS-IS15
Static60(可改)
RIP100
BGP-External255

数值越小越优先 → 静态路由 60 默认低于 OSPF 高于 BGP

浮动静态路由:把备份链路静态路由优先级调高(数值更大)

配置三步走

1 基础 IPv4 静态路由

system-view
ip route-static <目的网络> <掩码> <下一跳IP|出接口>

2 默认路由(最常用)

ip route-static 0.0.0.0 0.0.0.0 <下一跳IP>

3 验证

display ip routing-table
display ip routing-table protocol static

高级用法

浮动静态路由 主备链路

# 主链路 优先级默认 60
ip route-static 192.168.10.0 24 10.1.1.2

# 备链路 优先级 100(数值越大越不优先)
ip route-static 192.168.10.0 24 10.2.1.2 preference 100

主链路 down 后 备链路自动接管

静态路由 + BFD 联动 毫秒级切换

# 1 建 BFD 会话
bfd
 quit
bfd to_R2 bind peer-ip 10.1.1.2 source-ip 10.1.1.1
 discriminator local 1
 discriminator remote 1
 commit

# 2 静态路由绑 BFD
ip route-static 192.168.10.0 24 10.1.1.2 track bfd-session to_R2

对端 BFD 检测到链路 down 立即触发路由切换(毫秒级 比物理 down 检测快)

静态路由 + NQA 联动 端到端探测

# 1 创建 NQA 探测
nqa test-instance admin to_server
 test-type icmp
 destination-address ipv4 8.8.8.8
 frequency 5
 start now

# 2 静态路由绑 NQA
ip route-static 0.0.0.0 0.0.0.0 10.1.1.2 track nqa admin to_server

NQA 探测失败 → 路由失效 → 切到备份

永久发布

ip route-static 10.0.0.0 8 NULL0 permanent

即使出接口 down 也保留路由(黑洞路由防环用)

IPv6 静态路由

ipv6
ipv6 route-static 2001:db8::1 64 fe80::1 GigabitEthernet0/0/1
ipv6 route-static :: 0 2001:db8::1            # IPv6 默认路由
display ipv6 routing-table

命令体系

配置

命令视图说明
ip route-static <net> <mask> <next-hop>|<if>system创建静态路由
ip route-static <net> <mask> <nh> preference <pref>system指定优先级
ip route-static <net> <mask> <nh> tag <tag>system路由 tag
ip route-static <net> <mask> <nh> description <text>system描述
ip route-static <net> <mask> <nh> track bfd-session <name>systemBFD 联动
ip route-static <net> <mask> <nh> track nqa <admin> <name>systemNQA 联动
ip route-static <net> <mask> <nh> permanentsystem永久发布
ip route-static <net> <mask> <if> permanentsystem出接口永久
ip route-static default-preference <pref>system改默认优先级
ip route-static vpn-instance <vpn> <net> <mask> <nh>systemVPN 实例静态

IPv6

命令视图说明
ipv6system启用 IPv6
ipv6 route-static <net> <prefix-len> <nh> [<if>]systemIPv6 静态

查看

命令说明
display ip routing-table全路由表
display ip routing-table protocol static仅静态
display ip routing-table <ip>查指定网段
display ip routing-table <ip> longer-match最长匹配
display ip routing-table verbose详细
display ip routing-table statistics路由统计
display ipv6 routing-tableIPv6 路由表
display bfd session allBFD 会话状态
display nqa resultsNQA 结果

完整范式 双出口主备 + BFD

需求:出口路由器 R1 主 R2 备 主链路 ISP1 故障 50ms 切换 ISP2

system-view

# 1 BFD 全局开
bfd

# 2 配置到 R1 R2 的 BFD 会话
bfd to_isp1 bind peer-ip 10.1.1.2 source-ip 10.1.1.1
 discriminator local 100
 discriminator remote 100
 commit
 quit
bfd to_isp2 bind peer-ip 10.2.1.2 source-ip 10.2.1.1
 discriminator local 200
 discriminator remote 200
 commit
 quit

# 3 默认路由 主链路绑 BFD
ip route-static 0.0.0.0 0.0.0.0 10.1.1.2 track bfd-session to_isp1

# 4 默认路由 备链路 优先级调低(数值大)
ip route-static 0.0.0.0 0.0.0.0 10.2.1.2 preference 100

常见陷阱

  • 下一跳不可达(路由表里查不到下一跳)→ 静态路由不生效
  • 出接口配错 → 配 next-hop IP 更稳 出接口适合点对点链路
  • 浮动静态优先级搞反 → 备链路反成主
  • BFD 没 commit → 配了等于没配
  • IPv6 静态路由忘了先 ipv6 启用
  • NQA 频率太低(如 60s)→ 切换感知慢 改成 5s
  • 写了 ip route-static <net> <mask> <if> 但接口是以太网 → ARP 学习每个目的地址 性能差 改成 next-hop IP

排查流程

ping 不通
  |
  v
[1] display ip routing-table <目的IP> → 看是否有匹配路由
  |
  ├─ 无 → 走分支 A 路由未配置或失效
  └─ 有
       |
       v
   [2] 看 NextHop 是否可达 → ping <next-hop>
       |
       ├─ 不通 → 走分支 B 下一跳直连问题
       └─ 通 → 走分支 C 对端回程路由问题

相关文件

  • references/static-route-commands.md 完整命令
  • references/static-route-troubleshooting.md 故障排查

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.