1. 拓扑与地址规划
Internet / 传输网
202.100.100.10 | | 202.100.100.1 / .2
2001:100::10 | | 2001:100::1 / ::2
+---+---+ +----+----+ +----+----+
| HUB | | SPOKE1 | | SPOKE2 |
+---+---+ +----+----+ +----+----+
| | |
192.168.0.1/24 192.168.1.1/24 192.168.2.1/24
(LAN port2) (LAN port2) (LAN port2)
1.1 物理接口(WAN / LAN)
1.2 隧道 Overlay 规划(两套独立 ADVPN 域)
使用 ULA 地址(FC00::/7)作 v6 overlay 管理地址,避免与全局单播地址混淆。
1.3 优先级策略
两套 overlay 均全时建立,互为备份。
优先级控制方式:Spoke 上通过 BGP route-map-in 设置 Local-Preference 实现优先选路——
从 VPN6(FC00:10::1) 学到的路由:Local-Preference = 200
从 VPN4(10.10.10.1) 学到的路由:Local-Preference = 100
iBGP 选路时 Local-Pref 越高越优 → 默认走 v6 隧道,v6 隧道中断后自动收敛到 v4 隧道。
Spoke 之间的 shortcut 隧道同样分 v4/v6 两个 ADVPN 域独立建立,shortcut 选路继承 BGP Local-Pref 逻辑(v6 优先生效)。
1.4 BGP 规划
上游网关假设:v4 网关
202.100.100.254,v6 网关2001:100::254(请按现场实际修改)。
2. Hub 配置(FortiOS 7.2)
2.1 接口与静态路由
config system global
set hostname "HUB"
end
config system interface
edit "port1"
set mode static
set ip 202.100.100.10 255.255.255.0
set allowaccess ping https ssh
set role wan
config ipv6
set ip 2001:100::10/64
set allowaccess ping https ssh
end
next
edit "port2"
set mode static
set ip 192.168.0.1 255.255.255.0
set allowaccess ping https ssh
set role lan
config ipv6
set ip 2001:100:0::1/64
set allowaccess ping https ssh
end
next
end
config router static
edit 1
set dst 0.0.0.0/0
set gateway 202.100.100.254
set device "port1"
next
end
config router static6
edit 1
set dst ::/0
set gateway 2001:100::254
set device "port1"
next
end
2.2 IPsec Phase1(两个 ADVPN overlay,Hub 侧为 dynamic)
config vpn ipsec phase1-interface
edit "HUB-VPN4"
set type dynamic
set interface "port1"
set ike-version 2
set peertype any
set net-device disable
set add-route enable
set proposal aes256-sha256
set dhgrp 14
set dpd on-idle
set psksecret "Hub-ADVPN4-Psk"
set advpn enable
set role hub
set accept-dial-in 20
set ip 10.10.10.1 255.255.255.0
next
edit "HUB-VPN6"
set type dynamic
set interface "port1"
set ike-version 2
set peertype any
set net-device disable
set add-route enable
set add-route6 enable
set proposal aes256-sha256
set dhgrp 14
set dpd on-idle
set psksecret "Hub-ADVPN6-Psk"
set advpn enable
set role hub
set accept-dial-in 20
set ip 0.0.0.0 0.0.0.0
set ipv6 ip FC00:10::1/64
next
end
关键参数说明:
接口模式(interface mode)+ IKEv2 下无需手工定义 Phase2,FortiOS 自动使用
0.0.0.0/0与::/0流量选择器。
2.3 BGP(Route-Reflector,含 IPv4 / IPv6 地址族)
config router bgp
set as 65000
set router-id 10.10.10.1
config neighbor
edit "10.10.10.11"
set route-reflector-client enable
set add-path both
next
edit "10.10.10.12"
set route-reflector-client enable
set add-path both
next
end
config ipv6
config neighbor
edit "FC00:10::11"
set activate enable
set route-reflector-client enable
set add-path both
next
edit "FC00:10::12"
set activate enable
set route-reflector-client enable
set add-path both
next
end
config network
edit 1
set prefix 2001:100:0::/64
next
end
end
config network
edit 1
set prefix 192.168.0.0/24
next
end
end
add-path both:ADVPN 必需。Hub 作为 RR 向 Spoke 反射多条等价/非最优路径(携带原始下一跳),Spoke 才能拿到对端 Spoke 的隧道 IP 用于发起 shortcut。Hub 保留 iBGP 默认的 next-hop 不变行为(不要对 Spoke 邻居开 next-hop-self),否则 shortcut 无法正确发起。
2.4 防火墙策略
config firewall policy
edit 10
set name "LAN-to-Overlay"
set srcintf "port2"
set dstintf "HUB-VPN4" "HUB-VPN6"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
set logtraffic utm
next
edit 11
set name "Overlay-to-LAN"
set srcintf "HUB-VPN4" "HUB-VPN6"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
set logtraffic utm
next
edit 12
set name "Overlay-to-Overlay"
set srcintf "HUB-VPN4" "HUB-VPN6"
set dstintf "HUB-VPN4" "HUB-VPN6"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
end
ADVPN shortcut 隧道建立后会以
HUB-VPN4_x / HUB-VPN6_x形式的子接口出现,其流量同样匹配以 Phase1 接口名定义的策略。如需更严格的管控,可使用 Zone(Interface Zone)将 overlay 接口统一纳管。
3. Spoke1 配置(LAN 192.168.1.0/24)
3.1 接口与静态路由
config system global
set hostname "SPOKE1"
end
config system interface
edit "port1"
set mode static
set ip 202.100.100.1 255.255.255.0
set allowaccess ping https ssh
set role wan
config ipv6
set ip 2001:100::1/64
set allowaccess ping https ssh
end
next
edit "port2"
set mode static
set ip 192.168.1.1 255.255.255.0
set allowaccess ping https ssh
set role lan
config ipv6
set ip 2001:100:1::1/64
set allowaccess ping https ssh
end
next
end
config router static
edit 1
set dst 0.0.0.0/0
set gateway 202.100.100.254
set device "port1"
next
end
config router static6
edit 1
set dst ::/0
set gateway 2001:100::254
set device "port1"
next
end
3.2 IPsec Phase1(两条隧道分别指向 Hub 的 v4 / v6 地址)
config vpn ipsec phase1-interface
edit "SPOKE-VPN4"
set interface "port1"
set ike-version 2
set peertype any
set net-device disable
set add-route enable
set proposal aes256-sha256
set dhgrp 14
set dpd on-idle
set remote-gw 202.100.100.10
set psksecret "Hub-ADVPN4-Psk"
set advpn enable
set role spoke
set ip 10.10.10.11 255.255.255.0
set auto-negotiate enable
next
edit "SPOKE-VPN6"
set interface "port1"
set ike-version 2
set peertype any
set net-device disable
set add-route enable
set add-route6 enable
set proposal aes256-sha256
set dhgrp 14
set dpd on-idle
set remote-gw 2001:100::10
set psksecret "Hub-ADVPN6-Psk"
set advpn enable
set role spoke
set ip 0.0.0.0 0.0.0.0
set ipv6 ip FC00:10::11/64
set auto-negotiate enable
next
end
两条隧道的 Phase1 名称必须在所有 Spoke 上保持一致(
SPOKE-VPN4/SPOKE-VPN6),且 network-id 相同(默认 1),否则 Spoke 间 shortcut 无法匹配协商。PSK 必须与 Hub 对应 overlay 完全一致。
auto-negotiate enable:隧道常驻,保证 v4/v6 双通道同时在线。
3.3 路由图(v6 优先)
config router routemap
edit "PREF-V6"
config set
edit 1
set local-preference 200
next
end
next
edit "PREF-V4"
config set
edit 1
set local-preference 100
next
end
next
end
3.4 BGP
config router bgp
set as 65000
set router-id 10.10.10.11
config neighbor
edit "10.10.10.1"
set route-map-in "PREF-V4"
next
end
config network
edit 1
set prefix 192.168.1.0/24
next
end
config ipv6
config neighbor
edit "FC00:10::1"
set activate enable
set route-map-in "PREF-V6"
next
end
config network
edit 1
set prefix 2001:100:1::/64
next
end
end
end
选路逻辑:Spoke1 从 Hub 学到 192.168.2.0/24(v4 目的网段)时有两条路径——经 10.10.10.1(Local-Pref 100)与经 FC00:10::1(Local-Pref 200)→ 优选 v6 隧道;v6 隧道 DPD 超时断开后路由自动收敛到 v4 隧道。
3.5 防火墙策略
config firewall policy
edit 10
set name "LAN-to-Overlay"
set srcintf "port2"
set dstintf "SPOKE-VPN4" "SPOKE-VPN6"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
edit 11
set name "Overlay-to-LAN"
set srcintf "SPOKE-VPN4" "SPOKE-VPN6"
set dstintf "port2"
set srcaddr "all"
set dstaddr "all"
set action accept
set schedule "always"
set service "ALL"
next
end
Spoke 间流量:shortcut 未建立前经 Hub 中转(需 Hub 上 Overlay-to-Overlay 策略放行);shortcut 建立后直接走 Spoke 间隧道,同样命中上述 Overlay 相关策略。
4. Spoke2 配置(LAN 192.168.2.0/24)
与 Spoke1 完全同构,仅以下差异(其余照抄 Spoke1 并替换主机名):
Spoke2 的 Phase1 名称、PSK、ADVPN 参数必须与 Spoke1 完全一致。
5. 验证命令(7.2)
# 1. IKE 网关状态(应看到 4 条:2 条到 Hub + shortcut 建立后 Spoke 间 2 条)
diagnose vpn ike gateway list
# 2. 隧道流量/加解密统计
diagnose vpn tunnel list
# 3. ADVPN shortcut 状态(hub / spoke 角色、shortcut 邻居)
diagnose vpn advpn status
diagnose vpn advpn shortcut list
# 4. BGP 邻居(Hub 应看到 4 个 Established:v4×2 + v6×2)
get router info bgp summary
# 5. Spoke 路由表:确认远端 LAN 路由的下一跳在 FC00:10::x(v6 overlay)
get router info routing-table details 192.168.2.0/24
get router info routing-table details 2001:100:2::/64
# 6. 查看从 Hub 收到的路由及 Local-Pref
get router info bgp neighbors 10.10.10.1 routes
get router info bgp neighbors FC00:10::1 routes
验证要点:
Hub 上
get router info bgp summary中 4 个邻居全部 Established。Spoke 路由表中,远端 LAN 的 IPv4 路由下一跳为
FC00:10::1对应的 v6 overlay 递归出接口SPOKE-VPN6,即 v6 优先生效。Spoke1 ping Spoke2 LAN 地址并持续打流,观察
diagnose vpn tunnel list:初期流量走 Hub 中转,约 10~30 秒内 shortcut(SPOKE-VPN4_x/SPOKE-VPN6_x)协商建立,流量切换为直连。在 Hub/Spoke WAN 口模拟 v6 中断,确认 BGP 收敛后流量回落 v4 隧道。
6. 实施注意事项
Phase1 名称一致性:所有 Spoke 的
SPOKE-VPN4/SPOKE-VPN6名称、network-id、PSK、proposal、dhgrp 必须完全一致,否则 shortcut 协商失败。accept-dial-in 容量:Hub 数值 = Spoke 数 × 2(v4+v6)+ 预期 shortcut 数,配置 20 留有余量。
add-path 必须开启(v4 与 v6 地址族都要),否则 Hub 不会向 Spoke 反射通往对端 Spoke 的路径,ADVPN shortcut 无法建立。
NAT 环境提示:若 Spoke 位于 NAT 后,确保
set nat-traversal enable(7.2 默认开启);Hub 侧如有前置防火墙,需放行 UDP 500 / 4500(v4)以及 IKEv2 over IPv6 的相应端口。7.2 命令差异:个别低版本 7.2.x 中 Phase1 的 IPv6 远端网关若不支持直接写 IPv6 地址到
remote-gw,可检查是否有remote-gw6字段或升级到 7.2.5+。内核路由优先级兜底(可选):如需在 BGP 之外再加固 v6 优先,可在 Spoke 上对 BGP 路由配置
set distance或使用 SD-WAN 规则叠加管理,本方案以 Local-Pref 为主要手段,简单可靠。证书替代 PSK(可选加固):生产环境建议
set peertype one+ 证书认证替代 PSK。