在 OpenVPN 中设置静态 IP

Ian*_*man 1 ubuntu openvpn

我有一个 OpenVPN 服务器 (pivpn.io) 和三个服务器客户端。

我正在尝试为 VPN 客户端设置静态 IP 地址。

我已经创建了ipp.txt /etc/openvpn/ccd/ipp.txt.

该文件ipp.txt使用以下语法:

[客户端名称],[IP 地址] miami-test,10.8.0.5

连接服务器时不发出静态 IP 地址。

Mic*_*ton 5

这是因为这不是您手动分配 IP 地址的方式。OpenVPN 可以维护一个文件ipp.txt,以便客户端(有时)在重新连接或 OpenVPN 重新启动时获得重新分配给它们的相同 IP 地址。

请参阅示例配置:

# Maintain a record of client <-> virtual IP address
# associations in this file.  If OpenVPN goes down or
# is restarted, reconnecting clients can be assigned
# the same virtual IP address from the pool that was
# previously assigned.
ifconfig-pool-persist ipp.txt
Run Code Online (Sandbox Code Playgroud)

但这不是您配置的。

目录中的文件ccd被解释为特定于客户端的配置。因此,创建文件ccd/ipp.txt会导致 OpenVPN 尝试将文件的内容解释为应用于名为 的客户端的指令ipp.txt

这似乎不是您想要的。

让我们回到示例配置:

# To assign specific IP addresses to specific
# clients or if a connecting client has a private
# subnet behind it that should also have VPN access,
# use the subdirectory "ccd" for client-specific
# configuration files (see man page for more info).

# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2
Run Code Online (Sandbox Code Playgroud)

所以看起来您想要一个名为ccd/miami-test包含ifconfig-push 10.8.0.5 10.8.0.6.