Ping 工具
大约 4 分钟
Ping 工具
FortiGate CLI 的 execute ping 和 execute ping6 可配合 ping-options/ping6-options 调整报文参数,用于连通性、路由、SD-WAN 规则、MTU/分片、DNS 解析等场景的排查。
常用参数:
adaptive-ping:快速发出 Ping Request 报文(收到上一个 Echo Reply 后立即发送下一个 Echo Request,也就是快速 Ping)。repeat-count:指定 Ping 测试次数,避免默认次数不足或持续输出过多。source:指定源 IP,可用于模拟从不同网段发起的 FortiGate 本地流量。interface:指定出接口,可用于验证指定链路或路由方向。use-sdwan:指定是否让 Ping 流量参与 SD-WAN 规则和策略路由匹配。
IPv4 Ping 选项
查看 IPv4 Ping 可用选项:
execute ping-options ?常见选项如下:
execute ping-options adaptive-ping <enable|disable>
execute ping-options data-size <bytes>
execute ping-options df-bit {yes | no}
execute ping-options pattern <2-byte_hex>
execute ping-options interface <auto | interface_name>
execute ping-options interval <seconds>
execute ping-options repeat-count <repeats>
execute ping-options source {auto | <source-intf_ip>}
execute ping-options timeout <seconds>
execute ping-options tos <service_type>
execute ping-options ttl <hops>
execute ping-options validate-reply {yes | no}
execute ping-options view-settings
execute ping-options use-sdwan <yes | no>
execute ping-options reset参数说明
adaptive-ping <enable|disable>:开启后,收到上一个 Echo Reply 后立即发送下一个 Echo Request,也就是快速 Ping;默认为关闭状态,每秒 Ping 1 个包。data-size <bytes>:指定 ICMP 数据报文大小,单位为字节。df-bit {yes | no}:设置 DF bit。yes表示禁止分片,no表示允许分片,常用于 MTU/分片问题排查。pattern <2-byte_hex>:使用指定 2 字节十六进制内容填充 ICMP 末尾的数据缓冲区,可配合data-size测试不同报文大小对链路的影响。interface <auto | interface_name>:指定 Echo Request 的出接口。auto表示 FortiGate 根据目的地址查路由自动选择出接口。interval <seconds>:指定每次 Ping 之间的间隔。repeat-count <repeats>:指定 Ping 的发送次数。source {auto | <source IP>}:指定 Ping 的源 IP。auto表示 FortiGate 根据实际出接口自动选择源地址。指定不同网段的源 IP 可用于模拟不同源地址发起的连接。timeout <seconds>:指定等待 Echo Reply 的超时时间,单位为秒。tos <service_type>:设置 IP 头部 ToS 字段,表达期望的服务质量。ttl <hops>:指定 TTL,达到该跳数后报文会被丢弃或返回。validate-reply {yes | no}:设置是否校验返回报文中的数据内容。view-settings:查看当前 Ping 选项配置。use-sdwan <yes | no>:默认值为no。设置为yes后,Ping 流量会检查 SD-WAN 规则和策略路由,通常配合source使用,以验证特定源地址是否命中特定 SD-WAN 规则。reset:将 Ping 选项恢复为默认值。
tos 可用值如下:
tos 值 | ToS 字段 | 说明 |
|---|---|---|
default | 0x00 | 默认值。 |
lowcost | 0x02 | 尽量降低成本。 |
lowdelay | 0x10 | 尽量降低延迟。 |
throughput | 0x08 | 尽量提高吞吐。 |
reliability | 0x04 | 尽量提高可靠性。 |
使用示例
指定源 IP、出接口、测试次数,并让测试流量参与 SD-WAN 规则匹配:
execute ping-options reset
execute ping-options source 10.10.10.1
execute ping-options interface port1
execute ping-options repeat-count 5
execute ping-options use-sdwan yes
execute ping-options view-settings
execute ping 8.8.8.8使用 DF bit 和指定报文大小测试链路 MTU:
execute ping-options reset
execute ping-options df-bit yes
execute ping-options data-size 1472
execute ping 8.8.8.8测试完成后建议恢复默认值,避免后续 Ping 测试沿用旧参数:
execute ping-options reset使用 Ping 验证 DNS 解析
execute ping 也可以用于验证 FortiGate 是否能解析域名。目的地址填写域名后,如果输出中出现解析后的 IP 地址,说明域名解析成功。
execute ping google.com
PING google.com (142.250.179.78): 56 data bytesIPv6 Ping 选项
当 FortiGate 已开启 IPv6 功能可见性,并且接口配置了 IPv6 地址后,可以使用 execute ping6 测试 IPv6 连通性。
execute ping6 2001:db8::1查看 IPv6 Ping 可用选项:
execute ping6-options ?常见选项如下:
execute ping6-options adaptive-ping <enable|disable>
execute ping6-options data-size <bytes>
execute ping6-options interface <auto | outgoing_interface>
execute ping6-options interval <seconds>
execute ping6-options pattern <2-byte_hex>
execute ping6-options repeat-count <repeats>
execute ping6-options reset
execute ping6-options source6 <auto | IPv6_source_interface>
execute ping6-options timeout <seconds>
execute ping6-options tos <IPv6_type-of-service_value>
execute ping6-options ttl <time-to-live>
execute ping6-options use-sdwan <yes | no>
execute ping6-options validate-reply <yes | no>
execute ping6-options view-settingsIPv6 选项的用途基本与 IPv4 对应选项一致,但有两点差异:
- IPv4 中的
source在 IPv6 中对应为source6。 - IPv6 Ping 选项中没有
df-bit。