我试图在我的远程 Ubuntu 12.04 网络服务器上使用 OpenVPN,但是一旦 OpenVPN 运行,我就无法连接到互联网。
在启动 OpenVPN 之前,路由说:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default ip-172-31-16-1. 0.0.0.0 UG 100 0 0 eth0
172.31.16.0 * 255.255.240.0 U 0 0 0 eth0
之后:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.200.4.1 128.0.0.0 UG 0 0 0 tun0
default 172.31.16.1 0.0.0.0 UG 100 0 0 eth0
10.200.4.0 * 255.255.252.0 U 0 0 0 tun0
128.0.0.0 10.200.4.1 128.0.0.0 UG 0 0 0 tun0
172.31.16.0 * 255.255.240.0 U 0 0 0 eth0
184.170.137.2 172.31.16.1 255.255.255.255 UGH 0 0 0 eth0
184.170.137.2 是 VPN。OpenVPN HOWTO 建议使用
iptables -t nat -A POSTROUTING -s 10.200.4.0/22 -o eth0 -j MASQUERADE
抛出
sudo: unable to resolve host ip-172-31-26-178
(172.31.26.178 是内部 IP)。
如果我执行以下操作,我可以将 VPN 用于单个网站:
route add -net {website ip} netmask 255.255.255.255 gw 10.200.4.1 dev tun0
route del -net 0.0.0.0 netmask 128.0.0.0 dev tun0
route del -net 128.0.0.0 netmask 128.0.0.0 dev tun0
我怎样才能改变它以适用于整个网络?非常感谢您的帮助。