【问题标题】:Set OpenVPN client to use the local gateway in while maintaining client-to-client support将 OpenVPN 客户端设置为使用本地网关,同时保持客户端到客户端的支持
【发布时间】:2021-11-25 16:39:01
【问题描述】:

我想设置一个 vpn 以允许两台不同的计算机相互连接。 我找到了a bunch of places,他们说你应该从服务器配置中删除redirect-gateway def1 bypass-dhcp,并添加一个路由route 10.0.0.0 255.255.255.0 vpn_gateway,以便连接到专用网络。但这似乎不是我想要的。

是的,它现在通过我的本地网关发出所有请求(所有服务器都报告我的公共 ip 是我自己的 ip,而不是 vpn 的 ip),但现在连接到其他客户端不再有效。 我仍然可以连接到由 vpn 分配的我自己的私有 ip (10.0.0.0),但其他客户端无法通过同一个 ip 联系到我。

我的客户端.conf:

client
dev tun
proto udp
remote vpn.example.com 1194
resolv-retry infinite
nobind

user nobody
group nogroup

persist-key
persist-tun

remote-cert-tls server

cipher AES-256-GCM
auth SHA256

verb 3
key-direction 1

我的 server.conf:

port 1194
proto udp
dev tun

ca ca.crt
cert vpnserver.crt
key vpnserver.key

dh none
topology subnet

server 10.8.0.0 255.255.255.0
route 10.0.0.0 255.255.255.0

ifconfig-pool-persist /var/log/openvpn/ipp.txt

client-config-dir ccd

# push "redirect-gateway def1 bypass-dhcp"

push "route 10.0.0.0 255.255.255.0 vpn_gateway 1"

client-to-client
keepalive 10 120
tls-crypt ta.key

cipher AES-256-GCM
auth SHA256

user nobody
group nogroup

persist-key
persist-tun

status /var/log/openvpn/openvpn-status.log
verb 3
explicit-exit-notify 1

ccd/我的客户端

ifconfig-push 10.0.0.0 255.255.255.255

如何让client-to-client 工作而不使所有常规流量都通过 vpn?

编辑:经过更多试验后,我发现只要分配的私有 IP 在 10.8.0.x 范围内,此设置就可以正常工作。我在 10.0.0.x 范围内有一些静态私有 ip,所以这就是它不起作用的原因。不过我还是想用这些ip。

【问题讨论】:

    标签: networking openvpn


    【解决方案1】:

    我最终将服务器配置更改为使用 10.0.0.x 作为默认池。

    我变了:

    server 10.8.0.0 255.255.255.0
    route 10.0.0.0 255.255.255.0
    

    到

    server 10.0.0.0 255.255.255.0
    

    我不喜欢静态和动态 ip 现在都使用同一个池,但这是我能做的最好的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      • 2017-01-08
      • 1970-01-01
      • 2015-11-02
      • 2023-02-04
      • 1970-01-01
      相关资源
      最近更新 更多