我的OpenVPN服务器连接,我仍然可以访问互联网,但我无法访问局域网上的任何服务器。
我有一个虚拟networking,其IP范围为172.31.0.0/16
这个VNET有3个子网,分别是:
172.31.0.0/24
172.31.1.0/24
172.31.0.0/24
不去往VNET的stream量不需要经过VPN。
为server.conf
port 1194 proto udp dev tun ca /etc/openvpn/ca.crt cert /etc/openvpn/server.crt key /etc/openvpn/server.key # This file should be kept secret dh /etc/openvpn/dh2048.pem server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "route 172.31.0.0 255.255.0.0" push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 8.8.4.4" keepalive 10 120 tls-auth /etc/openvpn/ta.key 0 # This file is secret cipher AES-256-CBC user nobody group nobody persist-key persist-tun status openvpn-status.log verb 3
iptables的
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
客户
client dev tun proto udp remote XXXX 1194 route 172.31.0.0 255.255.0.0 vpn_gateway 3 resolv-retry infinite nobind persist-key persist-tun ca ca.crt cert client.crt key client.key tls-auth ta.key 1 ns-cert-type server cipher AES-256-CBC comp-lzo verb 1
IP转发configuration如下所示:
$ cat /proc/sys/net/ipv4/ip_forward 1
你的ip转发设置为什么?
cat /proc/sys/net/ipv4/ip_forward
如果它是0,那么你需要做的
echo 1 > /proc/sys/net/ipv4/ip_forward
我设法解决这个问题。 似乎在我的客户端configuration中启用了comp-lzo而不是我的服务器configuration导致它无法工作。 在服务器上启用它修复它。