OpenVPN“redirect-gateway def1bypass-dhcp”设置会终止 SSH 访问,但互联网访问需要它

OpenVPN“redirect-gateway def1bypass-dhcp”设置会终止 SSH 访问,但互联网访问需要它

我在 AWS 上的 Ubuntu 上运行 OpenVPN 服务器,其 server.conf 如下:

local x.x.x.x
port 1194
proto tcp
dev tap
ca ca.crt
cert server.crt
key server.key
dh dh.pem
auth SHA512
tls-crypt tc.key
topology subnet
server 10.8.0.0 255.255.0.0
push "redirect-gateway def1 bypass-dhcp"
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 10.43.1.12"
push "dhcp-option DNS 10.43.1.44"
client-config-dir /etc/openvpn/ccd
client-to-client
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
crl-verify crl.pem

我在多个 AWS 实例上安装了 OpenVPN 客户端,其中一些是 Ubuntu,一些是 Windows。它们都使用以下客户端配置:

client
dev tap
proto tcp
remote y.y.y.y 1194
resolv-retry infinite
nobind
persist-key
persist-tun
remote-cert-tls server
auth SHA512
cipher AES-256-CBC
ignore-unknown-option block-outside-dns
block-outside-dns
verb 3

我注意到,当我push "redirect-gateway def1 bypass-dhcp"从 server.conf 文件中删除该行时,Windows 客户端将无法再访问互联网(它们无法 ping 任何外部站点,并且浏览器停留在“解析主机”状态)。但我可以通过 SSH 顺利连接到 Ubuntu 客户端的私有 IP 地址 (10.109.xx),它们仍然可以访问互联网。

但是当我将该push "redirect-gateway def1 bypass-dhcp"行重新添加到 server.conf 文件中时,Windows 客户端可以访问互联网,但我无法再从我的 PC 通过 SSH 连接到 Ubuntu 客户端的私有 IP 地址 (10.109.xx)。奇怪的是,我仍然可以从 Windows 客户端通过 SSH 连接到 Ubuntu 客户端的私有 IP 地址。

我如何更改服务器配置以允许 Windows 客户端访问互联网并且 Ubuntu 客户端接受 SSH 连接?

答案1

最简单的方法是使用 VPN 中的 IP 地址通过 SSH 连接到 Ubuntu 客户端。

另一种选择是使用 OpenVPN 中客户端特定的配置文件,将其发送push "redirect-gateway def1 bypass-dhcp"给客户端。

第三个选项是修改 Windows 客户端的客户端配置文件并添加redirect-gateway def1 bypass-dhcp客户端配置。

相关内容