使用 PIA 设置 OpenVPN - 已连接但无互联网

使用 PIA 设置 OpenVPN - 已连接但无互联网

目前使用 Ubuntu Server 14.04(没有 GUI,全是终端),位于 VirtualBox 中,目前正在尝试让它连接到私人互联网接入利用他们的VPN 配置成立这里(对于那些想要查看其 opvm 文件的人来说,无需帐户即可下载)。

下载并解压 zip 文件后,我运行例如“sudo openvpn --config France.opvm”。这是输出。

Tue May 13 03:37:06 2014 UDPv4 link local: [undef]
Tue May 13 03:37:06 2014 UDPv4 link remote: [AF_INET]62.210.167.201:1194
Tue May 13 03:37:06 2014 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Tue May 13 03:37:07 2014 [Private Internet Access] Peer Connection Initiated with [AF_INET]62.210.167.201:1194
Tue May 13 03:37:09 2014 TUN/TAP device tun0 opened
Tue May 13 03:37:09 2014 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Tue May 13 03:37:09 2014 /sbin/ip link set dev tun0 up mtu 1500
Tue May 13 03:37:09 2014 /sbin/ip addr add dev tun0 local 10.135.1.10 peer 10.135.1.9
Tue May 13 03:37:09 2014 Initialization Sequence Completed

现在,据我所知,最后一行表示连接已建立。倒数第二行和第三行显示 OpenVPN 正在创建 IP 路由。如果我运行 ifconfig,我可以看到有一个新的 tun0 接口具有正确的 IP。

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          inet addr:10.135.1.10  P-t-P:10.135.1.9  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          RX bytes:0 (0.0 B)  TX bytes:336 (336.0 B)

但现在的问题是我无法访问互联网。Ping 不起作用,只是超时。我做错了什么,导致我无法连接?任何帮助我都会很感激。

答案1

您必须添加redirect-gateway到您的配置中(或使用openvpn --redirect-gateway):

--redirect-gateway [local] [def1]
    (Experimental) Automatically execute routing commands to cause all outgoing IP traffic to be redirected over the VPN.

    This option performs three steps:

    (1) Create a static route for the --remote address which forwards to the pre-existing default gateway. This is done so that (3) will not create a routing loop.

    (2) Delete the default gateway route.

    (3) Set the new default gateway to be the VPN endpoint address (derived either from --route-gateway or the second parameter to --ifconfig when --dev tun is specified).

    When the tunnel is torn down, all of the above steps are reversed so that the original default route is restored.

    Add the local flag if both OpenVPN servers are directly connected via a common subnet, such as with wireless. The local flag will cause step 1 above to be omitted.

    Add the def1 flag to override the default gateway by using 0.0.0.0/1 and 128.0.0.0/1 rather than 0.0.0.0/0. This has the benefit of overriding but not wiping out the original default gateway.

    Using the def1 flag is highly recommended, and is currently planned to become the default by OpenVPN 2.1.

相关内容