差異處
這裏顯示兩個版本的差異處。
| 兩邊的前次修訂版 前次修改 下次修改 | 前次修改 | ||
| tech:fortigate_tips [2018/06/18 08:23] – Jonathan Tsai | tech:fortigate_tips [2025/10/17 11:05] (目前版本) – [設定 HA] jonathan | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| + | ====== 有關 FortiGate 防火牆相關設定 ====== | ||
| + | * 設備型號 : FortiGate 40C (v5.2.13, | ||
| + | * WAN1 : 220.100.100.100 GW: 220.100.100.254 | ||
| + | * LAN(Internal) : 192.168.0.1 | ||
| + | ===== 基本設定 ===== | ||
| + | * 設定 WAN1 (wan1) | ||
| + | * 設定 LAN (intrtnal) | ||
| + | * 設定 Default Route | ||
| + | * System -> Network -> Routing | ||
| + | * Create New : | ||
| + | * Destination IP/Mask : 0.0.0.0/ | ||
| + | * Device : wain1 | ||
| + | * Gateway : 220.100.100.254 | ||
| + | * Policy & Objects -> Policy -> IPV4 | ||
| + | * Create New : | ||
| + | * Incoming Interface : internal | ||
| + | * Source Address : all | ||
| + | * Outgoing Interface : wan1 | ||
| + | * Destination Address : all | ||
| + | * Schedule : always | ||
| + | * Service : ALL | ||
| + | * Action : ACCEPT | ||
| + | |||
| + | ===== 設定 Port Mapping ===== | ||
| + | * 預計設定 WAN1 的 Port 80 / 443 -> 192.168.0.200: | ||
| + | * 定義 VIP : Polocy & Objects -> Objects -> Virtual IPs | ||
| + | - 建立 VIP : web-http 與 web-https ++看畫面|{{: | ||
| + | - 建立 VIP Group : webserver-group ++看畫面| \\ {{: | ||
| + | - 完成 VIP 建立 ++看畫面|{{: | ||
| + | - 確認與建立 Services : HTTP/HTTPS ++看畫面|{{: | ||
| + | * 定義 Policy : Policy & Objects -> Policy -> IPv4 | ||
| + | - 建立 wan1-> | ||
| + | - 完成 wan1-> | ||
| + | |||
| + | < | ||
| + | * 如果 Policy 中有啟動 NAT 轉過去的內部 Server 來源 IP 就會是 Fortigate 的 IP | ||
| + | * Exp. Fortigate 的 internal IP 是 192.168.0.1 在 21/ | ||
| + | </ | ||
| + | |||
| + | ===== 針對 Port Mapping (WAN 連入 Internal) (Virtual IP) 特定來源(黑名單)IP 設定技巧 ===== | ||
| + | * 透過 UI 設定 WAN -> Internal 的 Deny 規則後, 是無法實際阻擋特定來源 IP | ||
| + | * 但使用命令方式, | ||
| + | * 參考 - http:// | ||
| + | |||
| + | |||
| + | ===== 設定 SSL VPN ===== | ||
| + | * 建立使用者 : | ||
| + | - User & Device -> User -> User Group | ||
| + | * Create New : | ||
| + | * Name : vpn-user | ||
| + | * Type : Firewall | ||
| + | - User & Device -> User -> User Definition | ||
| + | * Create New : | ||
| + | - User Type : Local User | ||
| + | - Login Credentials : | ||
| + | * User Name : vpnuser1 | ||
| + | * Password : password1 | ||
| + | - Contact Info : | ||
| + | * Email Address | ||
| + | - Extra Info : | ||
| + | * [V] Enable | ||
| + | * [ ] Two-factor Authentication | ||
| + | * [V] User Group : vpn-user | ||
| + | * VPN -> SSL -> Portals | ||
| + | * Create New((免費只能建立一組, | ||
| + | * Name : ichiayi-sslvpn | ||
| + | * [V] Enable Tunnel Mode | ||
| + | * [V] Enable Split Tunneling | ||
| + | * Routing Address : SSLVPN_TUNNEL_ADDR1 | ||
| + | * Source IP Pooles : SSLVPN_TUNNEL_ADDR1 | ||
| + | * Client Options : [V] A;ways Up (Keep Alive) | ||
| + | * [V] Enable Web Mode | ||
| + | * Portal Message : Welcome to SSL VPN Service | ||
| + | |||
| + | < | ||
| + | * 設定帳號一次只能一個連線 : | ||
| + | * VPN -> SSL -> Portals -> 選擇指定的項目 Exp. full-access -> Edit | ||
| + | * [V] Limit Users to One SSL-VPN Connection at a Time | ||
| + | * ++點這裡看參考畫面|{{: | ||
| + | </ | ||
| + | |||
| + | ===== 防止暴力登入 SSL VPN 方式 ===== | ||
| + | * 參考 - https:// | ||
| + | * 當 Log & Report 的 VPN Events 出現大量 ssl-login-fail , sslvpn_login_unknown_user 狀況 | ||
| + | * 設定當 SSL VPN 登入失敗超過 x 次就鎖定 n 秒, 來降低嘗試暴力登入的狀況 Exp. 失敗超過 3 次, 就鎖 3600 秒< | ||
| + | config vpn ssl settings | ||
| + | set login-attempt-limit 3 | ||
| + | set login-block-time 3600 | ||
| + | end | ||
| + | </ | ||
| + | |||
| + | ===== 當出現 CPU 100% 時釐清問題方式 ===== | ||
| + | - 看哪個服務造成 < | ||
| + | FortiGate # diagnose sys top -d 3 | ||
| + | Run Time: 443 days, 19 hours and 44 minutes | ||
| + | 17U, 0N, 3S, 80I; 1838T, 1135F | ||
| + | | ||
| + | newcli | ||
| + | | ||
| + | Run Time: 443 days, 19 hours and 44 minutes | ||
| + | 26U, 0N, 3S, 71I; 1838T, 1135F | ||
| + | | ||
| + | httpsd | ||
| + | httpsd | ||
| + | |||
| + | FortiGate # | ||
| + | </ | ||
| + | - 先刪除這程序 < | ||
| + | - 針對這程序進行處理, | ||
| + | |||
| + | ===== IPSec - L2TP 用戶撥入 VPN 設定 ===== | ||
| + | * 參考 - http:// | ||
| + | |||
| + | ===== 設定多條 WAN 備援方式 ===== | ||
| + | * 參考 - http:// | ||
| + | |||
| + | ===== 路由偵錯檢測方式 ===== | ||
| + | * 參考 - http:// | ||
| + | * 連上 Fortigate 查看有經過這 FW 的 IP 流量訊息 Exp. 192.168.0.250 <code sh> | ||
| + | diag debug reset | ||
| + | diag debug flow filter clear | ||
| + | diagnose sniffer packet any "host 192.168.0.250 and icmp" 4 | ||
| + | </ | ||
| + | * 可以在外部 192.168.1.140 的 Windows 10 PC 執行 ping 與 tracert , 只要有經過 Fortigate 就會顯示流量訊息 | ||
| + | * ping 範例 ++PC 端 |< | ||
| + | C: | ||
| + | |||
| + | Ping 192.168.0.250 (使用 32 位元組的資料): | ||
| + | 回覆自 192.168.0.250: | ||
| + | 回覆自 192.168.0.250: | ||
| + | |||
| + | </ | ||
| + | TPFortiGate40C-1 # diag debug reset | ||
| + | |||
| + | TPFortiGate40C-1 # diag debug flow filter clear | ||
| + | |||
| + | TPFortiGate40C-1 # diagnose sniffer packet any "host 192.168.0.250 and icmp" 4 | ||
| + | interfaces=[any] | ||
| + | filters=[host 192.168.0.250 and icmp] | ||
| + | 5.053098 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 5.053240 internal out 192.168.1.140 -> 192.168.0.250: | ||
| + | 5.053447 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 5.053555 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 6.036276 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 6.036615 internal out 192.168.1.140 -> 192.168.0.250: | ||
| + | 6.036885 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 6.037006 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | |||
| + | 8 packets received by filter | ||
| + | 0 packets dropped by kernel | ||
| + | |||
| + | </ | ||
| + | * tracert 範例 ++PC 端 |< | ||
| + | C: | ||
| + | |||
| + | 在上限 30 個躍點上追蹤 192.168.0.250 的路由 | ||
| + | |||
| + | 1 1 ms 1 ms 1 ms 192.168.1.254 | ||
| + | 2 11 ms 10 ms 10 ms 192.168.0.254 | ||
| + | 3 14 ms 16 ms 15 ms 192.168.0.250 | ||
| + | |||
| + | 追蹤完成。 | ||
| + | </ | ||
| + | TPFortiGate40C-1 # diagnose sniffer packet any "host 192.168.0.250 and icmp" 4 | ||
| + | interfaces=[any] | ||
| + | filters=[host 192.168.0.250 and icmp] | ||
| + | 8.541353 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 8.541438 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 10.076119 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 10.076201 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 11.555745 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 11.555828 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 18.573750 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 18.583995 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 18.595516 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.118851 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.119128 internal out 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.120764 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.120917 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.132986 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.133519 internal out 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.135474 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.135559 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.151568 TPtoTN1 in 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.152277 internal out 192.168.1.140 -> 192.168.0.250: | ||
| + | 24.152673 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.152749 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.208985 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 24.209067 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 25.743512 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 25.743598 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | 27.209075 internal in 192.168.0.250 -> 192.168.1.140: | ||
| + | 27.209157 TPtoTN1 out 192.168.0.250 -> 192.168.1.140: | ||
| + | |||
| + | 27 packets received by filter | ||
| + | 0 packets dropped by kernel | ||
| + | </ | ||
| + | |||
| + | ===== FortiGate 60D 特別設定 ===== | ||
| + | ==== 端對端 VPN 使用 traceroute 非預期出現 DMZ IP ==== | ||
| + | * 參考 - http:// | ||
| + | traceroute 192.168.1.5 | ||
| + | |||
| + | traceroute to 192.168.1.5 (192.168.1.5), | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | * 只要設定 VPN 虛擬介面的 IP 即可解決 Exp. 192.168.101.254 ++看畫面|{{: | ||
| + | traceroute 192.168.1.5 | ||
| + | traceroute to 192.168.1.5 (192.168.1.5), | ||
| + | | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | ===== FortiGate 40C 特別設定 ===== | ||
| + | ==== 啟動 SNMP ==== | ||
| + | * https:// | ||
| + | |||
| + | ==== 建立 VLAN ==== | ||
| + | * http:// | ||
| + | * https:// | ||
| + | |||
| + | ==== 設定 HA ==== | ||
| + | * 參考手冊 - [[https:// | ||
| + | * 設定前確認 | ||
| + | - 兩台 FortiGate 的 Firmware 版本必須相同 Exp. v5.2.13, | ||
| + | - 兩台 FortiGate 的網路介面要先設定成固定 IP (不要 DHCP / PPPoE), 如果設定 Active-Passive 模式等 HA 建立完成後可再改回 DHCP or PPPoE((fortigate-ha-56.pdf Page.28)) | ||
| + | - 兩台 FortiGate 的設定幾乎相同 (Exp. 只有 hostname / Internal IP 不同 / wan IP 不同) | ||
| + | - 尚未設定 VDOM / HA ++CLI 語法|< | ||
| + | ichiayi-02-FG40C # get system ha status | ||
| + | Model: FortiGate-40C | ||
| + | Mode: standalone | ||
| + | Group: 0 | ||
| + | Debug: 0 | ||
| + | ses_pickup: disable | ||
| + | number of vcluster: 0 | ||
| + | </ | ||
| + | |||
| + | * 預計設定的 HA 架構與模式 | ||
| + | * 設定 HA 的模式 : FGCP Active-Active HA (這模式最多可以設定到四台 FortiGate((fortigate-ha-56.pdf Page.24))) | ||
| + | * 配置架構圖 | ||
| + | |||
| + | < | ||
| + | graph TD | ||
| + | Internet[" | ||
| + | Router[" | ||
| + | FG1[" | ||
| + | FG2[" | ||
| + | Switch[" | ||
| + | PC1[" | ||
| + | AP[" | ||
| + | PC2[" | ||
| + | | ||
| + | Internet < | ||
| + | Router --> | ||
| + | Router --> | ||
| + | FG1 < | ||
| + | FG1 --> | ||
| + | FG2 --> | ||
| + | Switch --> PC1 | ||
| + | Switch --> AP | ||
| + | Switch --> PC2 | ||
| + | | ||
| + | style Internet fill:# | ||
| + | style Router fill:# | ||
| + | style FG1 fill:# | ||
| + | style FG2 fill:# | ||
| + | style Switch fill:# | ||
| + | style PC1 fill:# | ||
| + | style AP fill:# | ||
| + | style PC2 fill:# | ||
| + | </ | ||
| + | |||
| + | * 設定方式 | ||
| + | - 每一台都登入啟用 HA ++CLI 語法|< | ||
| + | config system ha | ||
| + | set group-id 10 | ||
| + | set mode a-a | ||
| + | set hbdev wan2 50 | ||
| + | set group-name ichiayi_cluster | ||
| + | set load-balance-all enable | ||
| + | set password **Password** | ||
| + | end | ||
| + | </ | ||
| + | - 設定好 fortigate 應該會自動重開機 | ||
| + | - 經過一小段時間 HA 燈號會亮起 (如果是綠燈表示 HA 正常, 橘燈表示 HA 異常) | ||
| + | - 檢查 HA 相關資訊狀態 ++CLI 語法|< | ||
| + | get system ha status | ||
| + | </ | ||
| + | Model: FortiGate-40C | ||
| + | Mode: a-a | ||
| + | Group: 10 | ||
| + | Debug: 0 | ||
| + | ses_pickup: disable | ||
| + | load_balance: | ||
| + | load_balance_udp: | ||
| + | schedule: Round robin. | ||
| + | upgrade_mode: | ||
| + | Master:128 ichiayi-01-FG40C FGT40C391xxxxxx5 1 | ||
| + | Slave :128 ichiayi-02-FG40C FGT40C391xxxxxx1 0 | ||
| + | number of vcluster: 1 | ||
| + | vcluster 1: work 169.254.0.2 | ||
| + | Master:0 FGT40C391xxxxxx5 | ||
| + | Slave :1 FGT40C391xxxxxx1 | ||
| + | </ | ||
| + | get system ha</ | ||
| + | ichiayi-01-FG40C # get system ha | ||
| + | group-id | ||
| + | group-name | ||
| + | mode : a-a | ||
| + | password | ||
| + | hbdev : " | ||
| + | session-sync-dev | ||
| + | route-ttl | ||
| + | route-wait | ||
| + | route-hold | ||
| + | sync-config | ||
| + | encryption | ||
| + | authentication | ||
| + | hb-interval | ||
| + | hb-lost-threshold | ||
| + | helo-holddown | ||
| + | gratuitous-arps | ||
| + | arps : 5 | ||
| + | arps-interval | ||
| + | session-pickup | ||
| + | update-all-session-timer: | ||
| + | session-sync-daemon-number: | ||
| + | link-failed-signal | ||
| + | uninterruptible-upgrade: | ||
| + | ha-mgmt-status | ||
| + | ha-eth-type | ||
| + | hc-eth-type | ||
| + | l2ep-eth-type | ||
| + | ha-uptime-diff-margin: | ||
| + | vcluster2 | ||
| + | vcluster-id | ||
| + | override | ||
| + | priority | ||
| + | schedule | ||
| + | monitor | ||
| + | pingserver-monitor-interface: | ||
| + | pingserver-failover-threshold: | ||
| + | pingserver-slave-force-reset: | ||
| + | pingserver-flip-timeout: | ||
| + | load-balance-all | ||
| + | </ | ||
| + | get system status</ | ||
| + | ichiayi-01-FG40C # get system status | ||
| + | Version: FortiGate-40C v5.2.13, | ||
| + | Virus-DB: 52.00006(2017-09-28 20:11) | ||
| + | Extended DB: 1.00000(2012-10-17 15:46) | ||
| + | IPS-DB: 12.00234(2017-09-28 01:27) | ||
| + | IPS-ETDB: 0.00000(2001-01-01 00:00) | ||
| + | Serial-Number: | ||
| + | Botnet DB: 1.00000(2012-05-28 22:51) | ||
| + | BIOS version: 04000006 | ||
| + | System Part-Number: | ||
| + | Log hard disk: Not available | ||
| + | Internal Switch mode: switch | ||
| + | Hostname: ichiayi-01-FG40C | ||
| + | Operation Mode: NAT | ||
| + | FIPS-CC mode: disable | ||
| + | Current HA mode: a-a, master | ||
| + | Branch point: 762 | ||
| + | Release Version Information: | ||
| + | System time: Sat Jun 16 16:17:52 2018 | ||
| + | </ | ||
| + | ++ | ||
| + | - 連上 Slave 檢查 HA 相關狀態 ++CLI 語法|< | ||
| + | execute ha manage 0 | ||
| + | </ | ||
| + | ichiayi-01-FG40C # execute ha manage 0 | ||
| + | |||
| + | |||
| + | ichiayi-02-FG40C login: admin | ||
| + | Password: ******** | ||
| + | Welcome ! | ||
| + | </ | ||
| + | get system status | ||
| + | </ | ||
| + | ichiayi-02-FG40C # get system status | ||
| + | Version: FortiGate-40C v5.2.13, | ||
| + | Virus-DB: 52.00006(2017-09-28 20:11) | ||
| + | Extended DB: 1.00000(2012-10-17 15:46) | ||
| + | IPS-DB: 12.00234(2017-09-28 01:27) | ||
| + | IPS-ETDB: 0.00000(2001-01-01 00:00) | ||
| + | Serial-Number: | ||
| + | Botnet DB: 1.00000(2012-05-28 22:51) | ||
| + | BIOS version: 04000009 | ||
| + | System Part-Number: | ||
| + | Log hard disk: Not available | ||
| + | Internal Switch mode: switch | ||
| + | Hostname: ichiayi-02-FG40C | ||
| + | Operation Mode: NAT | ||
| + | FIPS-CC mode: disable | ||
| + | Current HA mode: a-a, backup | ||
| + | Branch point: 762 | ||
| + | Release Version Information: | ||
| + | System time: Sat Jun 16 16:20:05 2018 | ||
| + | </ | ||
| + | - < | ||
| + | * 如果對自動選擇的 Master 不滿意, 可以透過設定 priority 來指定(越大的數值優先當 Master) ++Exp. CLI語法| 連入後先將 Master 設定 200<code sh> | ||
| + | config system ha | ||
| + | set priority 200 | ||
| + | end | ||
| + | </ | ||
| + | execute ha manage 1 | ||
| + | |||
| + | config system ha | ||
| + | set priority 255 | ||
| + | end | ||
| + | </ | ||
| + | TPFortiGate40C-1 # get system ha status | ||
| + | Model: FortiGate-40C | ||
| + | Mode: a-a | ||
| + | Group: 10 | ||
| + | Debug: 0 | ||
| + | ses_pickup: disable | ||
| + | load_balance: | ||
| + | load_balance_udp: | ||
| + | schedule: Round robin. | ||
| + | upgrade_mode: | ||
| + | Master:255 TPFortiGate40C-1 FGT40C391xxxxxx7 1 | ||
| + | Slave :200 TPFortiGate40C-2 FGT40C391xxxxxx1 0 | ||
| + | number of vcluster: 1 | ||
| + | vcluster 1: work 169.254.0.2 | ||
| + | Master:0 FGT40C391xxxxxx7 | ||
| + | Slave :1 FGT40C391xxxxxx1 | ||
| + | < | ||
| + | </ | ||
| + | * 取消(解除) HA 設定 | ||
| + | * 直接連入要移除的那台 fortigate 執行系統重設 ++CLI語法|< | ||
| + | exec factoryreset </ | ||
| + | ichiayi-02-FG40C # exec factoryreset | ||
| + | This operation will reset the system to factory default! | ||
| + | Do you want to continue? (y/n)y | ||
| + | </ | ||
| + | * 連入將 ha mode 設定 standlone ++CLI語法|< | ||
| + | config system ha | ||
| + | set mode standalone | ||
| + | end | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== 參考網址 ===== | ||
| + | * https:// | ||
| + | * http:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | * http:// | ||
| + | |||
| + | {{tag> | ||