IKEV2 配置文件 IP 池

IKEV2 配置文件 IP 池

我在使用 IKEV2 配置 VPN 时遇到了一些问题。这是我的服务器配置文件

config setup

    #  Uncomment to allow few simultaneous connections with one user account.
    #  By default only one active connection per user allowed.
    # uniqueids=no

    # Increase debug level
    # charondebug = ike 3, cfg 3

conn %default

    # More advanced ciphers. Uncomment if you need it.
    # Default ciphers will works on most platforms.
    # ike=aes256gcm16-aes256gcm12-aes128gcm16-aes128gcm12-sha256-sha1-modp2048-modp4096-modp1024,aes256-aes128-sha256-sha1-modp2048-modp4096-modp1024,3des-sha1-modp1024!
    # esp=aes128gcm12-aes128gcm16-aes256gcm12-aes256gcm16-modp2048-modp4096-modp1024,aes128-aes256-sha1-sha256-modp2048-modp4096-modp1024,aes128-sha1-modp2048,aes128-sha1-modp1024,3des-sha1-modp1024,aes128-aes256-sha1-sha256,aes128-sha1,3des-sha1!

    # Dead peer detection will ping clients and terminate sessions after timeout
    dpdaction=clear
    dpddelay=35s
    dpdtimeout=2000s

    keyexchange=ikev2
    auto=add
    rekey=no
    reauth=no
    fragmentation=yes
    #compress=yes

    # left - local (server) side
    leftcert=mydomain.net.crt # Filename of certificate located at /etc/ipsec.d/certs/
    leftsendcert=always
    # Routes pushed to clients. If you don't have ipv6 then remove ::/0
    leftsubnet=0.0.0.0/0

    # right - remote (client) side
    eap_identity=%identity
    # ipv4 and ipv6 subnets that assigns to clients. If you don't have ipv6 then remove it
    rightsourceip=192.168.0.0/24
    rightdns=192.168.0.1,8.8.8.8

# Windows and BlackBerry clients usually goes here
conn ikev2-mschapv2
    rightauth=eap-mschapv2

# Apple clients usually goes here
conn ikev2-mschapv2-apple
    rightauth=eap-mschapv2
    leftid=mydomain.net

问题是我已经指定rightsourceip=192.168.0.0/24,因此每个新客户端都会在这个网络中获得 IP,但当然我的本地网络中已经有计算机了。

当我尝试连接到我的 VPN 时,它可以连接,但客户端获得的 IP 地址是 192.168.0.1,即路由器的 IP。

此外,我在这个网络中还有其他设备和电脑,因此客户端将获得现有的 IP 问题。

我的路由器充当 DHCP 服务器,IP 为 192.168.0.1

我尝试搜索正确的 IP 池配置,但没有找到任何信息。

我不确定这是否可行,但如果我可以将 IP 地址租用路由到我的路由器而不是通过 VPN 服务器租用地址,那就太好了(据我猜测,如果我错了,请纠正我)。

请帮我解决这个问题。谢谢。

答案1

您有多种选择,这些选择也在 strongSwan 的转发和拆分隧道维基页面:

  1. 虚拟 IP(例如 192.168.100.0/24),然后正确路由流量(因此服务器 LAN 中的主机不会将发往该子网的数据包发送到其默认网关,而是发送到 VPN 服务器)或将客户端的流量 NAT 到服务器自己的 IP 地址(因此在其他主机看来,流量来自 VPN 服务器,并且它们可以轻松对其做出响应)。
  2. 从为此保留的 192.168.0.0/24 子网中分配地址,并且不要用于服务器 LAN 上的其他主机(例如 192.168.0.192/26,如果足够大且超出 DHCP 范围且不用于静态分配的地址)。
  3. 使用DHCP服务插入从现有的 DHCP 服务器为您的客户端请求 192.168.0.0/24 之外的虚拟 IP。

后两种选项需要使用法普插入因为您正在从服务器端主机所连接的同一子网分配 IP。

相关内容