一、组网需求
如图所示,某公司总部内部有一台OA服务器,其余分2个支机构都需要通过vpn拨入总部内网对OA服务器进行访问,为了方便配置,总部不想有太多的配置,总部只建立一条vpn隧道,实现所有分支机构和总部的通讯。同时需要运行动态路由协议将总部和分支的路由全部打通。SPOKE所有的流量都通过HUB进行中转。非ADVPN。
二、网络拓扑
HUB and SPOKE通过动态路由学习到整网的业务网段路由,SPOKE之间相互的流量全部通过HUB进行中装,配置举例拓扑图:
VPN Tunnel IP地址分配,以及BGP的规划:
三、配置要点
1、配置FortiGate1
2)HUB端IPsec VPN的配置
2、配置FortiGate2
2)SPOKE(SH)端的IPsec VPN的配置
3、配置FortiGate3
2)SPOKE(GZ)端的IPsec VPN的配置
说明:如果要删除IPSEC VPN第一阶段、第二阶段时,需要先删除被调用的路由与防火墙安全策略。
四、配置步骤
1、配置FortiGate1 (BJ)---HUB--- FortiGate1-HQ-BJ
1) 基本上网配置
配置详细过程请参照 "路由模式典型功能--单线上网--静态地址线路上网配置"一节:
接口IP配置如下:
路由配置如下
2)HUB端的IPsec VPN的配置
config
vpn ipsec phase1-interface
edit "ADVPN"
set type dynamic
set interface "port1"
set peertype any
set proposal des-md5 des-sha1
set dpd on-idle
set exchange-interface-ip enable
set add-route disable
set net-device disable
set tunnel-search nexthop
set psksecret Fortinet123#
set dpd-retryinterval 60
next
end
注意:
1.由于总部需要与各种不通类型(静态IP/PPPOE)的SPOKE之间建立IPsec VPN,因此HUB需选择dynamic模式
2.新版本ADVPN主模式和野蛮模式,旧版本不支持野蛮模式,通常我们选择主模式即可
3.必须开启“exchange-interface-ip enable”,没有使用ADVPN的时候,必须要开启这条命令,用于HUB告知Spoke自己的Overlay IP是10.10.10.1,以便对方路由的下一条更变为10.10.10.1,这是一种比mode-cfg更好的dia over bgp/ospf的实现方式。(diagnose vpn ike gateway list :virtual-interface-addr: 10.10.10.1 -> 10.10.10.2)
4.由于使用了BGP动态路由协议,因此需要关闭自动添加路由的功能“add-route disable”
5.“net-device disable”是新版本的默认方式,保持默认的disable即可
5.“tunnel-search nexthop”由于需要通过路由去查找路由的下一跳,因此选择成nexthop,而不选择感兴趣流
config
vpn ipsec phase2-interface
edit "ADVPN"
set phase1name "ADVPN"
set proposal des-md5 des-sha1
set keepalive enable
next
end
config
system interface
edit "ADVPN"
set vdom "root"
set ip 10.10.10.1 255.255.255.255
set allowaccess ping
set type tunnel
set remote-ip 10.10.10.254
255.255.255.0
set role lan
set interface "port1"
next
end
注意:1.remote-ip 10.10.10.254是不被Spoke所使用的预留IP,IPsec Tunnel是一个点对点的隧道,但是ADVPN中这条隧道需要同时对应多个SPOKE,因此不能将Remote IP写成一个存在的SPOKE端IP。
config
router bgp
set as 100
set router-id 10.10.10.1
config neighbor-group --neighbor-group特性
edit
"ADVPN-PEERS"
set remote-as 100
set route-reflector-client enable --设置RR(路由反射器)
next
end
config
neighbor-range
edit 1
set prefix
10.10.10.0 255.255.255.0
set neighbor-group
"ADVPN-PEERS"
next
end
config network
edit 1
set prefix
192.168.0.0 255.255.255.0 -发布路由
next
end
注意:1.利用BGP neighbor-group特性,只要匹配前缀列表10.10.10.0/24的BGP-Peer均可以和HUB建立BGP邻居。
2.将邻居设置为Route-Reflector-Client,自己即为路由反射器(Route-Reflector),通过路由反射器原理实时同步整网路由。
config
firewall policy
edit 2
set name "VPN-IN"
set srcintf "ADVPN"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 3
set name "VPN-OUT"
set srcintf "port2"
set dstintf "ADVPN"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 4
set name "SPOKE-TO-SPOKE"
set srcintf "ADVPN"
set dstintf "ADVPN"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
end
注意:一定注意配置SPOKE之间的放通策略
2、配置FortiGate2 (SH)---SPOKE--- FortiGate2-Branch-SH
1) 基本上网配置
接口IP配置如下:
路由通过DHCP自动获取到默认路由:
2)SPOKE(SH)端的IPsec VPN的配置
config
vpn ipsec phase1-interface
edit "ADVPN"
set interface "port1"
set peertype any
set proposal des-md5 des-sha1
set exchange-interface-ip enable
set remote-gw 100.1.1.1
set psksecret Fortinet123#
next
end
注意:
1. 由于总部HUB的公网IP是固定的,因此分部配置静态的IPsec VPN
2. 必须开启“exchange-interface-ip enable”,没有使用ADVPN的时候,必须要开启这条命令,用于SPOKE告知HUB自己的Overlay IP是10.10.10.2,以便对方路由的下一条更变为10.10.10.2,这是一种比mode-cfg更好的dia over bgp/ospf的实现方式。(diagnose vpn ike gateway list :virtual-interface-addr: 10.10.10.1 -> 10.10.10.2)
配置IPsec VPN第二阶段
config
vpn ipsec phase2-interface
edit "ADVPN"
set phase1name "ADVPN"
set proposal des-md5 des-sha1
set auto-negotiate enable
next
end
config
system interface
edit "ADVPN"
set vdom "root"
set ip 10.10.10.2 255.255.255.255
set allowaccess ping
set type tunnel
set remote-ip 10.10.10.1 255.255.255.0
set role lan
set interface “port1”
next
end
config
router bgp
set as 100
set router-id 10.10.10.2
config neighbor
edit
"10.10.10.1" \\只需要与HUB建立BGP邻居即可
set remote-as 100
next
end
config network
edit 1
set prefix 192.168.1.0 255.255.255.0 \\发布业务网段
next
end
config
firewall policy
edit 2
set name "VPN-IN"
set srcintf "ADVPN"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 3
set name "VPN-OUT"
set srcintf "port2"
set dstintf "ADVPN"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
3、配置FortiGate3 (GZ)---SPOKE--- FortiGate3-Branch-GZ
1) 基本上网配置
接口IP配置如下:
路由通过PPPOE自动获取到默认路由:
2)SPOKE(GZ)端的IPsec VPN的配置
config
vpn ipsec phase1-interface
edit "ADVPN"
set interface "port1"
set peertype any
set proposal des-md5 des-sha1
set exchange-interface-ip enable
set remote-gw 100.1.1.1
set psksecret Fortinet123#
next
end
注意:
1. 由于总部HUB的公网IP是固定的,因此分部配置静态的IPsec VPN
2. 必须开启“exchange-interface-ip enable”,没有使用ADVPN的时候,必须要开启这条命令,用于SPOKE告知HUB自己的Overlay IP是10.10.10.3,以便对方路由的下一条更变为10.10.10.3,这是一种比mode-cfg更好的dia over bgp/ospf的实现方式。(diagnose vpn ike gateway list :virtual-interface-addr: 10.10.10.1 -> 10.10.10.3)
config
vpn ipsec phase2-interface
edit "ADVPN"
set phase1name "ADVPN"
set proposal des-md5 des-sha1
set auto-negotiate enable
next
end
config
system interface
edit "ADVPN"
set vdom "root"
set ip 10.10.10.3 255.255.255.255
set allowaccess ping
set type tunnel
set remote-ip 10.10.10.1 255.255.255.0
set role lan
set interface “port1”
next
end
config
router bgp
set as 100
set router-id 10.10.10.2
config neighbor
edit
"10.10.10.1" \\只需要与HUB建立BGP邻居即可
set remote-as 100
next
end
config network
edit 1
set prefix 192.168.2.0 255.255.255.0 \\发布业务网段
next
end
config
firewall policy
edit 2
set name "VPN-IN"
set srcintf "ADVPN"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 3
set name "VPN-OUT"
set srcintf "port2"
set dstintf "ADVPN"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
以上HUB/Spoke1/Spoke2全部配置完毕。
在HUB/SPOKE1/SPOKE2状态观察:
HUB
IPsec VPN建立情况:
Monitor--->IPsec
Monitor
HUB路由学习情况:
Monitor--->Routing
Monitor
FortiGate1-HQ-BJ # get router info routing-table all
S* 0.0.0.0/0 [10/0] via 100.1.1.254, port1
C 10.10.10.0/24 is directly connected,
ADVPN
C 10.10.10.1/32 is directly connected,
ADVPN
C 100.1.1.0/24 is directly connected,
port1
C 192.168.0.0/24 is directly connected,
port2
B 192.168.1.0/24 [200/0] via 10.10.10.2,
ADVPN, 07:56:26
B 192.168.2.0/24 [200/0] via 10.10.10.3,
ADVPN, 07:57:58
SPOKE1
IPsec VPN建立情况(只和HUB建立IPsec):
Monitor--->IPsec
Monitor
SPOKE1路由学习情况:
Monitor--->Routing
Monitor
FortiGate2-Branch-SH
# get router info routing-table all
S* 0.0.0.0/0 [5/0] via 101.1.1.254, port1
C 10.10.10.0/24 is directly connected,
ADVPN
C 10.10.10.2/32 is directly connected,
ADVPN
C 101.1.1.0/24 is directly connected,
port1
B 192.168.0.0/24 [200/0] via 10.10.10.1,
ADVPN, 07:55:45
C 192.168.1.0/24 is directly connected,
port2
B 192.168.2.0/24 [200/0] via 10.10.10.3,
ADVPN, 07:55:45
S 192.168.91.0/24 [10/0] is directly
connected, port1
SPOKE2
IPsec VPN建立情况(只和HUB建立IPsec):
Monitor--->IPsec
Monitor
SPOKE2路由学习情况:
Monitor--->Routing
Monitor
FortiGate3-Branch-GZ
# get router info routing-table all
S* 0.0.0.0/0 [5/0] via 102.1.1.254, ppp0
C 10.10.10.0/24 is directly connected,
ADVPN
C 10.10.10.3/32 is directly connected,
ADVPN
C 102.1.1.1/32 is directly connected, ppp0
C 102.1.1.254/32 is directly connected,
ppp0
B 192.168.0.0/24 [200/0] via 10.10.10.1,
ADVPN, 08:02:06
B 192.168.1.0/24 [200/0] via 10.10.10.2,
ADVPN, 08:00:15
C 192.168.2.0/24 is directly connected,
port2
S 192.168.91.0/24 [10/0] via 102.1.1.254, ppp0
HUB 侧 VPN状态查看: