Strongswan中2个SA中的重叠子网如何确定要走哪个隧道?

Strongswan中2个SA中的重叠子网如何确定要走哪个隧道?

我有 ikev1 的 2 个隧道,左子网和右子网重叠,发送的数据包如何知道它首先转发到哪个隧道_4a010003 那是什么以及我如何决定数据包将转发到哪个隧道?我的配置是:

# cat /etc/ipsec.conf
conn %default
        keyexchange=ikev1
        authby=secret
        type=tunnel
        include ipsec.*.conf
conn second_4a010001
        left=50.50.50.11 #
        leftsubnet=20.20.20.0/28 
        right=50.50.50.50
        rightsubnet=30.30.30.0/28 
        esp=aes128gcm64-aes128gcm128-aes128gcm96-modp2048 
        lifetime=9999s 
        lifebytes=313032704
        auto=route 
conn first_4a010003
        left=10.10.10.11 
        leftsubnet=20.20.20.0/24 
        right=10.10.10.10 
        rightsubnet=30.30.30.0/24
        esp=aes128-sha1-modp2048 
        lifetime=8000s 
        lifebytes=313032704 
        auto=route

什么时候将数据包发送到 30.30.30.30 并将到达哪个隧道?

# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.17.235.1    0.0.0.0         UG    1      0        0 eth0
10.10.10.0      0.0.0.0         255.255.255.0   U     0      0        0 eth2
20.20.20.0      0.0.0.0         255.255.255.0   U     0      0        0 eth5
50.50.50.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1

# ip route
default via 172.17.235.1 dev eth0  proto none  metric 1 notify
10.10.10.0/24 dev eth2  proto kernel  scope link  src 10.10.10.11
20.20.20.0/24 dev eth5  proto kernel  scope link  src 20.20.20.20 linkdown
50.50.50.0/24 dev eth1  proto kernel  scope link  src 50.50.50.11
172.17.235.0/24 dev eth0  proto kernel  scope link  src 172.17.235.236

答案1

这是由出站 IPsec 策略及其优先级决定的。您可以使用命令查看这些内容ip xfrm policy。安装此类策略时,strongSwan 对更具体的策略使用更高的优先级(更低的数值)。例如,寻址到的数据包30.30.30.1将使用为该地址创建的 SA第二_4a010001连接(只要源地址位于20.20.20.0/28),因为/28子网将导致比/24子网更高的优先级。

但是,寻址到的数据包30.30.30.30将使用通过其他连接创建的 SA,因为该地址不是/28子网的一部分。

相关内容