Fortinet公司 第 1页 / 共 23页 www.fortinet.com.cn
FGT配合天翼电信 3G/4G网卡实现链路与 VPN备份
版本 1.0
时间 2015年 3月
支持的版本 FortiOS v4.3.18, v5.0.11
作者 李威峰
状态 草稿
Fortinet公司 第 2页 / 共 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公司 第 3页 / 共 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公司 第 4页 / 共 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公司 第 5页 / 共 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公司 第 6页 / 共 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公司 第 7页 / 共 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公司 第 8页 / 共 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公司 第 9页 / 共 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公司 第 11页 / 共 23页 www.fortinet.com.cn
中心端:
配置阶段 1,阶段 2 配置,略。
配置隧道路由,不需要,因为使用时拨号方式,中心端会根据分支端提供的第二阶段 local
Fortinet公司 第 12页 / 共 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公司 第 13页 / 共 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公司 第 14页 / 共 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公司 第 15页 / 共 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公司 第 16页 / 共 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公司 第 17页 / 共 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公司 第 18页 / 共 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公司 第 19页 / 共 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公司 第 20页 / 共 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 2.2.2.0/24 is directly connected, wan2
C 3.3.3.0/24 is directly connected, internal
C 4.4.4.0/24 is directly connected, lookback1
C 172.19.0.0/26 is directly connected, V101
C 172.19.0.64/26 is directly connected, V102
C 172.19.0.128/26 is directly connected, V103
Fortinet公司 第 21页 / 共 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公司 第 22页 / 共 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断开过程)