Strongswan客户访问权限

Pet*_* W. 1 strongswan

我是 Strongswan 的初学者,所以我对这个初学者\xe2\x80\x99s 查询表示歉意。我用 Strongswan 创建了 Debian 服务器。通过 Mikrotik LTE 路由器和 IKEv2-PSK 协议连接到该服务器的三个网络\nnetwork_1:192.168.10.0/24、network_2:192.168.20.0/24 和 network_3 192.168.30.0/24。与这些网络一起,可以通过 IKEv2 协议和 MSCHAP-EAP 身份验证将 Windows、iOS、OSX 和 Android 客户端连接到该服务器。一切工作都没有问题,并且每个连接的客户端都可以访问所有这三个网络中的所有 IP。

\n\n

目前,我想为 MSCHAP-EAP 客户端 \xe2\x80\x93 分配以下一些访问权限,例如:

\n\n

客户端 Bob/password1 应该只能访问网络 2 中的 IP,而不能访问其他 IP\n客户端 Alice/password2 应该只能访问第二个网络中的 IP 地址范围 192.168.20.100 \xe2\x80\x93 150,而不能访问其他 IP\n客户端John/password3 应该只能访问 IP 地址范围 192.168.30.10 \xe2\x80\x93 50 和 192.168.10.150 -200 以及 IP 地址 192.168.20.44

\n\n

有哪位好心人能帮我解决一下吗?理想情况下参考解决方案\xe2\x80\xa6的任何示例

\n\n

先感谢您

\n\n

彼得

\n

ecd*_*dsa 5

一种可能的方法是使用 EAP-RADIUS。radius 服务器可以返回可与配置( ipsec.conf 中的rightgroups或swanctl.conf 中的)匹配的属性。然后,您可以为每个组定义不同的本地流量选择器。ikev2 /rw-eap-md5-class-radius StrongSwan 测试场景说明了这一点。

如果您不想或不能使用 EAP-RADIUS,有一种方法可以匹配各个 EAP 身份,但这有点棘手,因为 StrongSwan 不完全支持基于此类身份的连接切换。为此,必须使用与假组的虚拟连接。ipsec.conf 中的内容如下:

conn eap-shared
   # options shared by all clients e.g.
   leftcert=...
   # or
   rightsourceip=...
   # or
   rightauth=eap-mschapv2

conn eap-init
   also=eap-shared
   # this config is used to do the EAP-Identity exchange and the
   # authentication of client and server
   eap_identity=%identity
   # the following is used to force a connection switch after
   # the authentication completed
   rightgroups=<any string that is not used as group/class>
   auto=add

conn eap-bob
   also=eap-shared
   eap_identity=bob@strongswan.org
   # any options that only apply to this user follow here e.g.
   leftsubnet=192.168.20.0/24
   auto=add

conn eap-alice
   also=eap-shared
   eap_identity=alice@strongswan.org
   # any options that only apply to this user follow here e.g.
   # (note that ipsec.conf does not support ranges, and most kernel
   #  interfaces do neither, so a range might be converted to a larger
   #  subnet when installing IPsec policies, so deaggregating the range
   #  is the most accurate way to do this currently)
   leftsubnet=192.168.20.100/30,192.168.20.104/29,192.168.20.112/28,192.168.20.128/28,192.168.20.144/30,192.168.20.148/31,192.168.20.150/32
   auto=add

conn eap-john
   also=eap-shared
   eap_identity=john@strongswan.org
   # any options that only apply to this user follow here e.g.
   # (see above)
   leftsubnet=192.168.30.10/31,192.168.30.12/30,192.168.30.16/28,192.168.30.32/28,192.168.30.48/31,192.168.30.50/32,192.168.10.150/31,192.168.10.152/29,192.168.10.160/27,192.168.10.192/29,192.168.10.200/32,192.168.20.44/32
   auto=add
Run Code Online (Sandbox Code Playgroud)

使用 EAP-RADIUS,配置看起来非常相似,但您不需要连接eap-init(而是添加eap_identity=%identityeap-shared),并且不必eap_identity在每个单独的连接中定义您设置的rightgroups组(即 EAP-RADIUS 类属性值)应该使用该连接(即,这允许多个用户使用相同的 conn 部分)。