我正在尝试设置一个OpenVPN tun来连接两个lan的
开放的vpn连接已经启动和工作,但我的路由或nat等方面存在问题。
我需要的是一个示例,说明在服务器和客户端运行的、路由为openvpn的安装程序应该是什么样的。主要有路由表、Nat翻译、防火墙等。
以下是我所做的工作:

我的OpenVPN客户端可以访问服务器端的网络,但我的服务器甚至不能打开我的OpenVpn客户机的eth0
我的服务器路由:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.254 0.0.0.0 UG 0 0 0 eth0 10.8.0.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0 10.8.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0 169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.3.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0 192.168.4.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0
我的客户路由:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.64.64.64 0.0.0.0 UG 0 0 0 3g-wan 10.8.0.0 10.8.0.9 255.255.255.255 UGH 0 0 0 tun0 10.8.0.9 0.0.0.0 255.255.255.255 UH 0 0 0 tun0 10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 3g-wan 192.168.1.0 10.8.0.9 255.255.255.0 UG 0 0 0 tun0 192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.4.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
这是openvpn使用以下命令自动设置的:
push "route 192.168.1.0 255.255.255.0"路线192.168.3.0 255.255.255.0
路线192.168.4.0 255.255.255.0
和客户端-config-dir中的iroute命令。
如果有人能提出一些我需要检查的东西,我会非常感激亚历克斯
编辑1#
OpenVPN服务器Config:
port 1194
proto udp
dev tun
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/mom_server.crt
key /etc/openvpn/keys/mom_server.key
dh /etc/openvpn/keys/dh1024.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "route 192.168.1.0 255.255.255.0"
client-config-dir /etc/openvpn/ccd
client-to-client
route 192.168.3.0 255.255.255.0
push "route 192.168.3.0 255.255.255.0"
route 192.168.4.0 255.255.255.0
push "route 192.168.4.0 255.255.255.0"
keepalive 10 120
comp-lzo
user nobody
chroot /etc/openvpn
group nogroup
daemon
persist-key
persist-tun
status openvpn-status.log
verb 3In /etc/openvpn/ccd/flexo_client
iroute 192.168.3.0 255.255.255.0
iroute 192.168.4.0 255.255.255.0编辑2#
我有这样的工作,请看这里的解决方案:
发布于 2016-03-31 00:30:50
OP在forums.openvpn.net上发布了答案
使用此服务器配置:
port 1194
proto udp
dev tun
topology subnet
mode server
tls-server
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt # flexo_client,10.8.0.4
client-config-dir ccd
client-to-client
#ifconfig 10.8.0.1 255.255.255.0
route 192.168.3.0 255.255.255.0 10.8.0.4
route 192.168.4.0 255.255.255.0 10.8.0.4
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/mom_server.crt
key /etc/openvpn/keys/mom_server.key # This file should be kept secret
dh /etc/openvpn/keys/dh1024.pem
keepalive 10 120i
comp-lzo
user nobody
chroot /etc/openvpn
group nogroup
daemon
persist-key
persist-tun
status openvpn-status.log
verb 3使用此/etc/openvpn/ccd/flexo_client
push "route 192.168.1.0 255.255.255.0 10.8.0.1"
iroute 192.168.3.0 255.255.255.0
iroute 192.168.4.0 255.255.255.0这个客户端配置:
config openvpn 'flexo_client'
option nobind '1'
option float '1'
option client '1'
option comp_lzo '1'
option dev 'tun0'
option verb '3'
option persist_tun '1'
option persist_key '1'
option remote_cert_tls 'server'
option remote 'x.x.x.x'
option proto 'udp'
option resolv_retry 'infinite'
option ca '/etc/openvpn/ca.crt'
option cert '/etc/openvpn/flexo_client.crt'
option key '/etc/openvpn/flexo_client.key'
option ns_cert_type 'server'
option topology 'subnet'
option enable '1' 有关使用OpenVPN与iroute的更多信息可以在backreference.org上找到。
发布于 2018-07-16 12:57:53
我也遇到过一个类似的问题,我最初能够从服务器连接到客户端,但经过一段时间的不活动之后,我失去了这种能力。我在用
静态密钥、p2p拓扑、udp协议和TUN
我已经通过添加
keepalive 20 120服务器和客户端。这将导致每20秒发送一次ping,如果120秒没有应答而传递,则假定删除连接。
https://serverfault.com/questions/593314
复制相似问题