FortiGate上面检查网络连通性的三个步骤
1、适用范围
所有的运行在NAT或者TP模式下面的FortiGate设备。
2、说明
本文描述的是在FortiGate上面检查网络连通性的三个典型步骤,这三个步骤的输出信息同样对于FortiGate技术支持中心来说是非常有用的也是提交tcket必须的附件。
我们假设的网络环境如下显示:
[ PC1 ] === portA [ FortiGate ] portB ==== [ PC2]
PC1和PC2分别直连在FortiGate的portA和portB口上或者是跨过路由器连到FortiGate的portA和portB口上,出现的问题是PC1不能连接到PC2。
3、解决方案
注意:在使用了NP2网络处理器的FortiGate接口上,由于网络流量有可能被NP2处理器硬件加速从而导致sniffer和debug flow输出结果错误。请在使用这2个命令前先确认你所使用的FortiGate设备是否具有NP2接口,如果是NP2接口的话请参照“如何在FortiGate的NP2网络接口上面使用sniffer或debug flow功能”文章描述禁用NP2硬件加速功能。
大体上的故障排除过程如下:
步骤一:sniffer
步骤二:debug flow
步骤三:session list
步骤一,sniffer
可以让PC1持续的ping着PC2然后确认如下几个问题结果:
- Ping请求包是否从所期望的FortiGate网口收到;
- 检查ARP请求是否正确的从目的接口发出去;
- 检查ping请求包是否从期望的FortiGate几口发出去;
- 检查ping响应是否从上面的出接口收到;
- 检查ping响应是否正确的从FortiGate的portA口发向PC1。
具体命令如下:
FGT# diagnose sniffer packet any "host <PC1> or host <PC2>" 4
或者
FGT# diagnose sniffer packet any "(host <PC1> or host <PC2>) and icmp" 4
在sniffer过滤器里面可以同时增加ARP协议,这样有助于发现到PC2的ARP请求响应是否正确。
具体命令如下:
FGT# diagnose sniffer packet any "host <PC1> or host <PC2> or arp" 4
敲“CTRL+C”可以中止sniffer
Sniffer命令参数‘4’可以显示出报文具体的进口和出口。
步骤二,debug flow
正确的ping包应该可以正常的穿过FortiGate,如果没有正常穿越,可以尝试用debug flow命令来查找问题:
diag debug enable
diag debug flow filter add <PC1> 或者 diag debug flow filter add <PC2>
diag debug flow show console enable
diag debug flow trace start 100 <== 这样可以查看到前100个报文
diag debug enable
要停止debug flow,可以使用命令 "diag debug flow trace stop"
1,下面是debug flow具体的数据流由于没有匹配上了防火墙策略而被阻挡输出:
id=20085 trace_id=319 func=resolve_ip_tuple_fast line=2825 msg="vd-root received a packet(proto=6, 192.168.129.136:2854->192.168.96.153:1863) from port3."
id=20085 trace_id=319 func=resolve_ip_tuple line=2924 msg="allocate a new session-013004ac"
id=20085 trace_id=319 func=vf_ip4_route_input line=1597 msg="find a route: gw-192.168.150.129 via port1"
id=20085 trace_id=319 func=fw_forward_handler line=248 msg=" Denied by forward policy check"
2,下面是debug flow具体的数据流匹配上了防火墙基于策略IPSEC VPN策略ID=2的输出:
id=20085 trace_id=1 msg="vd-root received a packet (proto=1, 10.72.55.240:1->10.71.55.10:8) from internal."
id=20085 trace_id=1 msg="allocate a new session-00001cd3"
id=20085 trace_id=1 msg="find a route: gw-192.168.56.230 via wan1"
id=20085 trace_id=1 msg="Allowed by Policy-2: encrypt"
id=20085 trace_id=1 msg="enter IPsec tunnel-RemotePhase1"
id=20085 trace_id=1 msg="encrypted, and send to 192.168.225.22 with source 192.168.56.226"
id=20085 trace_id=1 msg="send to 192.168.56.230 via intf-wan1“
id=20085 trace_id=2 msg="vd-root received a packet (proto=1, 10.72.55.240:1-10.71.55.10:8) from internal."
id=20085 trace_id=2 msg="Find an existing session, id-00001cd3, original direction"
id=20085 trace_id=2 msg="enter IPsec ="encrypted, and send to 192.168.225.22 with source 192.168.56.226“ tunnel-RemotePhase1"
id=20085 trace_id=2 msgid=20085 trace_id=2 msg="send to 192.168.56.230 via intf-wan1"
步骤三,session list
再进一步的故障分析可以检查防火墙的连接表,连接表查看支持过滤器设置,可以根据具体的源目的IP地址或端口等信息过虑需要查看的防火墙连接表信息,具体如下:
diag sys session filter src PC1
diag sys session list
或者
diag sys session filter dst PC1
diag sys session list
清楚过虑器过虑出来的防火墙连接的命令如下:
diag sys session filter dst PC1
diag sys session clear