我使用OpenVZ在Ubuntu 14.04 VPS上设置了OpenVPN服务器。 我可以通过客户端build立到VPN的连接。 我可以访问一些像Google和Twitter这样的网页,但很多站点无法加载。
我把这个添加到iptables中:
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source my-server-ip
我的server.conf看起来像这样:
port 1194 proto udp dev tun ca ca.crt cert my-cert.crt key my-key.key # This file should be kept secret dh dh2048.pem server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 8.8.4.4" keepalive 10 120 comp-lzo persist-key persist-tun status openvpn-status.log verb 3
尝试只使用一个DNS服务器。 可能是其中一个DNS服务器不接受传入的请求。 在我的设置中,我只需将dhcp-option DNS指向我的tun0'inet addr:'即可。 在服务器上运行ifconfig以查明该地址是什么。 像10.8.xx.xx一样
它可能通过在客户端和服务器configuration上的设置来修复。 看到OpenVPN常见问题“我可以ping通隧道,但是任何真正的工作都会导致它被锁住,这是MTU问题吗?
我的问题是,我编辑iptables,但从来没有保存(从害怕搞乱以前的规则)。
通过使用这个:
sudo /etc/init.d/networking restart
我能够testing我的iptables是否在不保存的情况下工作。