FortiGate 流量排錯用固定順序:封包有沒有進來、route 選哪裡、policy_id 是多少、SNAT/DNAT 結果、UTM 是否丟棄、回程是否存在。Debug flow 要有窄 filter 和明確 stop。
Policy 與設定盤點
查看 Firewall PolicyFortiGate CLI
show firewall policy先找 policyid、srcintf、dstintf、address、service、NAT 與 security profiles。
查看完整 Policy 預設值FortiGate CLI
show full-configuration firewall policy輸出很長,先在測試設備或精確 edit context 內看。
查看 Address ObjectsFortiGate CLI
show firewall address找 subnet、FQDN 與 interface 綁定是否正確。
查看 VIPFortiGate CLI
show firewall vip核對 extip、mappedip、extintf、port forward 與 ARP 行為。
查看 IP PoolFortiGate CLI
show firewall ippoolSNAT pool 範圍、overload 與路由要一起看。
備份設定到本機 flashFortiGate CLI
execute backup config flash pre-change.conf仍要下載離機保存;檔案可能含加密或敏感設定。
顯示目前設定 checksumFortiGate CLI
diagnose sys config checksum showHA/變更比對時使用;不同 scope 要按版本文件判讀。
Session 與 Debug Flow
清除 Debug 與 filterFortiGate CLI
diagnose debug reset
diagnose debug flow filter clear每次開始前先清乾淨。
設定來源與目的 filterFortiGate CLI
diagnose debug flow filter saddr 192.168.50.10
diagnose debug flow filter daddr 198.51.100.20addr 不能一次塞兩個 IP;分用 saddr/daddr。
加入目的 Port 與 TCPFortiGate CLI
diagnose debug flow filter dport 443
diagnose debug flow filter proto 6proto 6 是 TCP;先用 ? 核對當版。
顯示 function 與 timestampFortiGate CLI
diagnose debug flow show function-name enable
diagnose debug console timestamp enable便於對照 policy、DNAT、route 與 drop。
開始有限筆數 TraceFortiGate CLI
diagnose debug flow trace start 50
diagnose debug enable先產生測試流量,收滿 50 筆或完成後立即 stop。
停止並清除 DebugFortiGate CLI
diagnose debug flow trace stop
diagnose debug disable
diagnose debug flow filter clear
diagnose debug reset不論是否抓到都要執行。
以相同五元組抓 SnifferFortiGate CLI
diagnose sniffer packet any 'host 192.168.50.10 and host 198.51.100.20 and port 443' 4 50 lDebug flow 看決策,sniffer 看實際封包;兩者互相驗證。
IPsec VPN 與 IKE
查看 IPsec Tunnel 摘要FortiGate CLI
get vpn ipsec tunnel summary看 up/down、selectors 與 traffic counters。
查看 Phase 1 GatewayFortiGate CLI
diagnose vpn ike gateway list確認 peer、state、proposal、NAT-T 與 DPD。
查看 Phase 2 TunnelFortiGate CLI
diagnose vpn tunnel list確認 proxyid、SA、enc/dec packets、lifetime 與 errors。
查看 VPN EventsFortiGate CLI
execute log filter category 1
execute log display本機 log 可用性依儲存與設定;完成重設 log filter。
設定 IKE peer filterFortiGate CLI
diagnose vpn ike log-filter dst-addr4 203.0.113.50先鎖定單一 peer,避免全域 IKE debug。
開始 IKE DebugFortiGate CLI
diagnose debug application ike -1
diagnose debug enable只重現一次協商;輸出可能很大。
停止 IKE DebugFortiGate CLI
diagnose debug disable
diagnose debug reset
diagnose vpn ike log-filter clear版本若不支援 clear,先用 ? 查當版語法。
指定來源測 VPN 對端FortiGate CLI
execute ping-options source 10.10.10.1
execute ping 10.20.20.1
execute ping-options resetsource 和目的必須包含在路由與 phase2 selector。
怎麼確認有做對
- Debug flow 顯示正確 policy_id、route、NAT 與 accept,sniffer 有雙向封包。
- VPN Phase 1/2 SA 存在,enc/dec counter 隨測試增加。
- 所有 debug、log filter、ping options 已停止與 reset,設定備份可讀。
常見錯誤
- debug flow 沒有限定 IP/port。
- 為了看到 offloaded session 就關掉核心 policy 的 ASIC offload。
- 只有 enc 增加就認為 VPN 正常,沒看 dec 與回程。
- IKE debug 抓完忘記關。
常見問題
Debug flow 為什麼看不到明明存在的 session?
流量可能已由 NPU offload。優先用 sniffer、session detail 或機型支援的 NPU capture;不要直接關閉高流量 policy 的 offload。
VPN 顯示 up,應用還是不通?
Tunnel up 只代表 SA。還要查 phase2 selector、route、policy、NAT exemption、MTU、對端回程與 enc/dec counter。
延伸閱讀
版本與官方文件
參數會隨工具版本與作業系統實作改變。正式環境先用 --help、-h 或系統內建說明確認,再以當版官方文件為準。
常見問題
Debug flow 為什麼看不到明明存在的 session?
流量可能已由 NPU offload。優先用 sniffer、session detail 或機型支援的 NPU capture;不要直接關閉高流量 policy 的 offload。
VPN 顯示 up,應用還是不通?
Tunnel up 只代表 SA。還要查 phase2 selector、route、policy、NAT exemption、MTU、對端回程與 enc/dec counter。