FGT 配合天翼电信 3G/4G 网卡实现链路与 VPN 备份 版本 1.0 时间支持的版本作者状态反馈 2015 年 3 月 FortiOS v4.3.18, v5.0.11 李威峰草稿 support_cn@fortinet.com Fortinet 公司第 1 页 / 共 23 页 www.fortinet.com.cn
目录 介绍...3 测试环境...3 环境介绍...3 组件...4 配置过程...4 1. 基本的网络配置, 略... 5 2. 配置 modem...5 3. 插入 3G/4G 上网卡, 重启设备 ( 如果插入后拨不上号但是可以识别, 通过重启设备解决 )...8 4. 配置 modem 接口上的 VPN...8 5. 配置调整 - 优化配置... 12 测试及诊断... 13 场景 1... 13 场景 2... 18 场景 3... 21 场景 4... 22 参考资料... 23 Fortinet 公司第 2 页 / 共 23 页 www.fortinet.com.cn
介绍 在偏远地区或出于成本原因,3G 或 4G 无线网卡配合 3G/4G 路由器成为一种上网的选择, 本文介绍 FGT 配合 3G/4G 网卡实现线路的冗余与 VPN 备份 其中 VPN 备份内容介绍的较为粗略, 只要是为了证明能够在该条链路上使用 IPSec VPN 及拨号时间 本文测试使用电信网卡为 huawei EC3372-871,FGT80C 基于 FortiOS 4.3.18(v5.0.11 已经过测试亦可 ), 联通 E1750 配置与此相同, 不用自定义 3G-modem 测试环境 环境介绍 支行与分行通过 3G modem 创建 VPN 隧道 ; FGT300D 模拟分行,FGT80C 模拟支行,FGT100D 模拟专线 其中 : FGT300D lookback1 为 5.5.5.5 /24, 模拟墙后面的一台主机 FGT80C lookback1 为 4.4.4.4 /24, 模拟墙后面的一台主机. 两台主机通过 VPN 互通 Fortinet 公司第 3 页 / 共 23 页 www.fortinet.com.cn
FGT80C WAN2 地址为 2.2.2.2 网关配置为 2.2.2.1, 启用网关检测功能 模拟 WAN2 各种场景下 Modem 及 VPN 的行为 组件 序号组件名称软件版本数量备注 1 FortiGate-80C V4.3.18 (v5.0.11) 1 也可以是别的带 USB 接口的 FGT 设备 2 电信 huawei EC3372-871 1 联通 E1750 除了不需要自定义 modem, 配置与该文档相同, 可 参考此文档 配置过程 配置总步骤 1. 启用 3G modem 启用后 modem 相当于一个物理接口, 防火墙策略,VPN 路由都可以使用该接口 2. 配置 modem 拨号字符串及拨号方式设置为冗余模式, 设置为 WAN2 接口的备份 ( 配置拨号字符串, 自定义 modem 等 ) 3. 配置 modem 接口下启用自动生成网关 4. 配置 WAN2 网关检测 ping 上一跳地址, 如果不可达, 删除该接口路由, 并通知 WAN down 5. 配置在 modem 接口上的 VPN 在第 1,2 阶段启用自动协商. 1 阶段自动拨号为 30 秒, 可以调整为 1 秒 到 VPN 隧道的路由可以调整为 distance 为 20. 6. 参数微调 3G/4G holdontimer // 默认 60 秒, 可以调整为 15 秒 Fortinet 公司第 4 页 / 共 23 页 www.fortinet.com.cn
DPD( 分行, 支行 ), 因为 WAN2 突然中断或 model 中断, 分行 VPN 并不知道状态, 此时靠 DPD 清除假隧道 7. 诊断 1.Debug modem 拨号 ( 及断开 ) diagnose debug application modemd -1(0 是关闭 ) Diag debug enable 2.Debug vpn Diag debug app ike -1 Diag debug enable 3. 日志可以观察过程 1. 基本的网络配置, 略 2. 配置 modem 1. 启用 modem 在命令行下配置开启 Modem,WEB 管理界面网络接口部分显示 Modem 接口 config system modem set status enable end 配置后在网络 -> 接口处和调制解调器中显示 Fortinet 公司第 5 页 / 共 23 页 www.fortinet.com.cn
2. 配置拨号码并设置备份模式 config system modem set mode redundant // 设置模式 set holddown-timer 15 // 设置 holdown-timer 时间, 当监控的端口恢复状态时, 多长时间断开连接 set interface "wan2" // 设置监控端口当该接口故障或 ping 检测失败时,modem 开始拨号 set phone1 "*99#" // 设置拨号码 set distance 20 // 设置 distance 值, 可以不配置 end 启用后界面将显示 modem 及配置 网络 接口处显示 modem 接口 Fortinet 公司第 6 页 / 共 23 页 www.fortinet.com.cn
3. 配置 modem 接口 config system interface edit "modem" set vdom "root" set mode pppoe set distance 20 set allowaccess ping https ssh snmp http telnet fgfm // 管理权限, 可以不开启 set type physical set defaultgw enable // 启用默认自动生成网关 set dns-server-override disable next end 其它为默认配置 4. 因为电信 EC3372-871 因为不在 FGT modem 列表中, 需要自定义 ( 如果型号在列表中, 可以省略这步 ) config system 3g-modem custom edit 1 set vendor "Huawei" set model "EC3372" set vendor-id 12d1 set product-id 1f01 set init-string "inquire=1 msg=55534243000000000000000000000011060000000000000000000000000000" next Fortinet 公司第 7 页 / 共 23 页 www.fortinet.com.cn
edit 2 set vendor "Huawei" set model "EC3372" set vendor-id 12d1 set product-id 1442 set class-id ff next end 3. 插入 3G/4G 上网卡, 重启设备 ( 如果插入后拨不上号但是可以识别, 通过重启设备解决 ) 4. 配置 modem 接口上的 VPN 阶段 1: FGT80C3914603242 # show vpn ipsec phase1-interface config vpn ipsec phase1-interface edit "modem-to-fh" set interface "modem" set keylife 86400 set mode aggressive // 配置野蛮模式 set proposal des-md5 set localid "test" // 配置 localid, 因为 IP 地址经过了 NAT, 中心端不能靠 IP 地址识别 身份, 所以要配置 localid set negotiate-timeout 1 // 自动重连时间, 默认为 30 秒钟, 此处修改为 1 秒钟 阶 段 1 默认启用了自动重连, 所以不必单独配置 且默认启用了 NAT 穿越 set remote-gw 59.108.29.180 set psksecret 123456 set dpd-retrycount 10 next Fortinet 公司第 8 页 / 共 23 页 www.fortinet.com.cn
end 阶段 2: config vpn ipsec phase2-interface edit "modem-to-fh-p2" set auto-negotiate enable // 启用阶段 2 自动连接, 否则没有流量触发阶段 2 不会自 动连接 set phase1name "modem-to-fh" set proposal des-md5 set dst-subnet 5.5.5.0 255.255.255.0 set src-subnet 4.4.4.0 255.255.255.0 next end 配置隧道路由 : FGT80C3914603242 # show router static config router static edit 1 set device "wan2" set gateway 2.2.2.1 next edit 2 set device "modem-to-fh" set distance 20 // 设置 distance 值为 20, 也可以保持默认 set dst 5.5.5.0 255.255.255.0 next end Fortinet 公司第 9 页 / 共 23 页 www.fortinet.com.cn
创建 lookback 接口 : 以便测试 创建 VPN 互通策略 Fortinet 公司第 10 页 / 共 23 页 www.fortinet.com.cn
中心端 : 配置阶段 1, 阶段 2 配置, 略 配置隧道路由, 不需要, 因为使用时拨号方式, 中心端会根据分支端提供的第二阶段 local Fortinet 公司第 11 页 / 共 23 页 www.fortinet.com.cn
network 自动生成 创建 lookback1 测试接口 5. 配置调整 - 优化配置 默认情况下, 当 WAN2 接口 down 时,modem 才能触发拨号 为了避免 WAN2 接口 up,modem 不拨号的情况, 启用 ping 检测配置 WAN2 ping 检测 config router gwdetect // v5.2.3 配置 config system link-monitor edit "wan2" set server "2.2.2.1" next end 调整 modem hold-down-timer config system modem set mode redundant // 设置模式备份模式 Fortinet 公司第 12 页 / 共 23 页 www.fortinet.com.cn
set holddown-timer 15 // 设置 holdown-timer 时间, 当监控的端口恢复状态时, 多长时间断开连接 set interface "wan2" // 设置监控端口当该接口故障或 ping 检测失败时,modem 开始拨号 set phone1 "*99#" // 设置拨号码 set distance 20 // 设置 distance 值, 可以不配置 end 测试及诊断 场景 1 拔掉 WAN2 网线,WAN2 物理端口 down,modem 自动连接, 同时 VPN 也自动连接 Fortinet 公司第 13 页 / 共 23 页 www.fortinet.com.cn
路由 : VPN: 日志 : 可以看到 VPN 在 WAN 拔线 7 秒后 ( 其中 6 秒 3G 拨号,1 秒 VPN 发起连接 ) 建立连接 Ping 测试 : 1.ping 互联网测试 FGT80C3914603242 # execute ping 8.8.8.8 PING 8.8.8.8 (8.8.8.8): 56 data bytes 64 bytes from 8.8.8.8: icmp_seq=0 ttl=38 time=268.2 ms Fortinet 公司第 14 页 / 共 23 页 www.fortinet.com.cn
64 bytes from 8.8.8.8: icmp_seq=1 ttl=38 time=252.8 ms 64 bytes from 8.8.8.8: icmp_seq=2 ttl=38 time=244.8 ms 64 bytes from 8.8.8.8: icmp_seq=3 ttl=38 time=271.8 ms 64 bytes from 8.8.8.8: icmp_seq=4 ttl=38 time=300.9 ms --- 8.8.8.8 ping statistics --- 5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 244.8/267.7/300.9 ms FGT80C3914603242 # execute ping www.baidu.com PING www.a.shifen.com (180.76.3.151): 56 data bytes 64 bytes from 180.76.3.151: icmp_seq=0 ttl=47 time=176.8 ms 64 bytes from 180.76.3.151: icmp_seq=4 ttl=47 time=158.8 ms --- www.a.shifen.com ping statistics --- 5 packets transmitted, 2 packets received, 60% packet loss round-trip min/avg/max = 158.8/167.8/176.8 ms sniffer 抓包 : FGT80C3914603242 # diagnose sniffer pa any 'icmp' 4 interfaces=[any] filters=[icmp] 44.971891 modem out 10.128.99.189 -> 8.8.8.8: icmp: echo request 45.198556 modem in 8.8.8.8 -> 10.128.99.189: icmp: echo reply 45.970103 modem out 10.128.99.189 -> 8.8.8.8: icmp: echo request 46.020055 root out 2.2.2.2 -> 2.2.2.2: icmp: host 2.2.2.1 unreachable 46.020055 root in 2.2.2.2 -> 2.2.2.2: icmp: host 2.2.2.1 unreachable VPN ping 测试 FGT80C3914603242 # execute ping-options source 4.4.4.4 // 指定源接口 FGT80C3914603242 # execute ping 5.5.5.5 PING 5.5.5.5 (5.5.5.5): 56 data bytes 64 bytes from 5.5.5.5: icmp_seq=0 ttl=255 time=40.9 ms 64 bytes from 5.5.5.5: icmp_seq=2 ttl=255 time=32.1 ms 64 bytes from 5.5.5.5: icmp_seq=3 ttl=255 time=33.1 ms Fortinet 公司第 15 页 / 共 23 页 www.fortinet.com.cn
64 bytes from 5.5.5.5: icmp_seq=4 ttl=255 time=33.1 ms --- 5.5.5.5 ping statistics --- 5 packets transmitted, 4 packets received, 20% packet loss round-trip min/avg/max = 32.1/34.8/40.9 ms 抓包, 说明确实经过了 VPN 隧道 FGT80C3914603242 # diagnose sniffer packet any 'host 5.5.5.5' 4 interfaces=[any] filters=[host 5.5.5.5] 3.207539 modem-to-fh out 4.4.4.4 -> 5.5.5.5: icmp: echo request 3.243100 modem-to-fh in 5.5.5.5 -> 4.4.4.4: icmp: echo reply 4.200075 modem-to-fh out 4.4.4.4 -> 5.5.5.5: icmp: echo request 4.233335 modem-to-fh in 5.5.5.5 -> 4.4.4.4: icmp: echo reply 5.200069 modem-to-fh out 4.4.4.4 -> 5.5.5.5: icmp: echo request 5.233319 modem-to-fh in 5.5.5.5 -> 4.4.4.4: icmp: echo reply 6.200078 modem-to-fh out 4.4.4.4 -> 5.5.5.5: icmp: echo request 6.241428 modem-to-fh in 5.5.5.5 -> 4.4.4.4: icmp: echo reply 7.200077 modem-to-fh out 4.4.4.4 -> 5.5.5.5: icmp: echo request 7.233413 modem-to-fh in 5.5.5.5 -> 4.4.4.4: icmp: echo reply 拨号过程 : FGT80C3914603242 # scan_usb_dev():628 scan_usb_dev():628 modemd: interface wan2, event type 1, state_change 2 //WAN2 down modem: wan2 link status is 0 modem: primary interface has failed - launch modem. modem: Begin dialing: redials left = 99999 modem state changed: 1(inactive) -> 2(dialing) //modem 开始拨号 chat: abort on (BUSY) chat: abort on (NO DIAL TONE) chat: abort on (NO DIALTONE) Fortinet 公司第 16 页 / 共 23 页 www.fortinet.com.cn
chat: abort on (NO CARRIER) chat: abort on (NO ANSWER) chat: abort on (ERROR) chat: send (atz^m) chat: expect (OK) chat: ^M chat: ^HCSQ: "LTE",42,32,131,22^M chat: ^M chat: ^HCSQ: "LTE",42,32,161,22^M chat: atz^m^m chat: OK chat: -- got it chat: send (ath0^m) chat: expect (OK) chat: ^M chat: ath0^m^m chat: OK chat: -- got it chat: send (ats7=90^m) chat: timeout set to 90 seconds chat: expect (OK) chat: ^M chat: ats7=90^m^m chat: OK chat: -- got it chat: send (atdt*99#^m) chat: expect (CONNECT) Fortinet 公司第 17 页 / 共 23 页 www.fortinet.com.cn
chat: ^M chat: atdt*99#^m^m chat: CONNECT chat: -- got it chat: send (^M) scan_usb_dev():628 modem: PPP is connected. modem state changed: 2(dialing) -> 3(connected) 连接成功 redails:0 isp:0 dev:/dev/ttyusb0 tel:*99# scan_usb_dev():628 scan_usb_dev():628 scan_usb_dev():628 scan_usb_dev():628 场景 2 插上 WAN2,modem 自动断开连接,VPN 自动断开 FGT80C3914603242 # diagnose debug enable FGT80C3914603242 # scan_usb_dev():628 scan_usb_dev():628 scan_usb_dev():628 modemd: interface wan2, event type 2, state_change 1 modem: wan2 link status is 16 modemd: pingserver 'wan2' status changed modem: wan2 link status is 16 modem: primary interface has recovered - holddown for 15 seconds. //Hold15 秒后断开连接 : modem state changed: 3(connected) -> 7(holddown) scan_usb_dev():628 scan_usb_dev():628 Fortinet 公司第 18 页 / 共 23 页 www.fortinet.com.cn
scan_usb_dev():628 modem: primary interface has recovered - disconnect modem. modem state changed: 7(holddown) -> 4(hangingup) chat: abort on (BUSY) chat: abort on (NO DIAL TONE) chat: abort on (NO CARRIER) chat: abort on (NO ANSWER) chat: abort on (ERROR) chat: send (ath^m) chat: expect (OK) modem: PPP has disconnected (222). //Hold15 秒后断开连接 : chat: ^M chat: NO CARRIER chat: -- failed chat: Failed (NO CARRIER) modem state changed: 4(hangingup) -> 0(uninit) modem state changed: 0(uninit) -> 1(inactive) modem: primary interface has recovered - reset_current_isp. redails:0 isp:0 dev:/dev/ttyusb0 tel:*99# scan_usb_dev():628 model 断开连接 : Fortinet 公司第 19 页 / 共 23 页 www.fortinet.com.cn
FGT80C3914603242 # get router info routing-table all Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default S* 0.0.0.0/0 [10/0] via 2.2.2.1, wan2 C C C C C C 2.2.2.0/24 is directly connected, wan2 3.3.3.0/24 is directly connected, internal 4.4.4.0/24 is directly connected, lookback1 172.19.0.0/26 is directly connected, V101 172.19.0.64/26 is directly connected, V102 172.19.0.128/26 is directly connected, V103 Fortinet 公司第 20 页 / 共 23 页 www.fortinet.com.cn
日志 : 场景 3 WAN2 ping 网关检测功能失败,modem 自动拨号,VPN 自动重连 KF (internal) # config secondaryip KF (secondaryip) # edit KF (secondaryip) # show config secondaryip edit 1 set ip 2.2.2.1 255.255.255.0 set allowaccess ping https ssh snmp http telnet fgfm next end KF (secondaryip) # edit 1 KF (1) # set ip 2.2.2.3 255.255.255.0 KF (1) # next 日志中 : 能够看到从看到 modem 拨号和 VPN 协商成功的信息 Fortinet 公司第 21 页 / 共 23 页 www.fortinet.com.cn
场景 4 WAN2 ping 网关检测功能检测成功,modem hold 15 秒钟自动断开,VPN 随之立即断开 可以从日志中观察过程 ( 也可以 diagnose debug application modemd -1 观察 modme 断开和 KF # diagnose debug application ike -1 观察 VPN 断开过程 ) Fortinet 公司第 22 页 / 共 23 页 www.fortinet.com.cn
参考资料 Fortinet 公司杜贵中 Fortigate 防火墙 4G 上网卡配置 Fortinet 公司第 23 页 / 共 23 页 www.fortinet.com.cn