我尝试在配置 openvpn 客户端后访问互联网,但无法完成。我的做法如下:
sudo /usr/sbin/openvpn --config /etc/openvpn/US\ East.ovpn >> /home/javi/log_file.log 2>&1 &
这就是我所拥有的美国东部.ovpn
client
dev tun
proto udp
remote us-east.privateinternetaccess.com 1198
resolv-retry infinite
nobind
persist-key
persist-tun
cipher aes-128-cbc
auth sha1
tls-client
remote-cert-tls server
auth-user-pass
comp-lzo
verb 1
reneg-sec 0
crl-verify /etc/openvpn/crl.rsa.2048.pem
ca /etc/openvpn/ca.rsa.2048.crt
disable-occ
auth-user-pass /etc/openvpn/piaauth.txt
运行上述命令后,我的 ifconfig 看起来像这样(enp3s0 是我的 eth0):
enp3s0 Link encap:Ethernet HWaddr bc:ae:--:--:--:--
inet addr:192.168.1.128 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::2970:1589:8ab:6f86/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:240340 errors:0 dropped:0 overruns:0 frame:0
TX packets:126235 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:353873769 (353.8 MB) TX bytes:9924327 (9.9 MB)
Interrupt:40
lo ......
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.137.1.6 P-t-P:10.137.1.5 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:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 B) TX bytes:1247 (1.2 KB)
路由表
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.134.1.5 128.0.0.0 UG 0 0 0 tun0
default 192.168.1.1 0.0.0.0 UG 100 0 0 enp3s0
10.134.1.1 10.134.1.5 255.255.255.255 UGH 0 0 0 tun0
10.134.1.5 * 255.255.255.255 UH 0 0 0 tun0
128.0.0.0 10.134.1.5 128.0.0.0 UG 0 0 0 tun0
link-local * 255.255.0.0 U 1000 0 0 enp3s0
192.168.1.0 * 255.255.255.0 U 100 0 0 enp3s0
209.222.23.61 192.168.1.1 255.255.255.255 UGH 0 0 0 enp3s0
跟踪路由 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 10.146.1.1 (10.146.1.1) 117.873 ms 118.239 ms 118.244 ms
2 107.191.35.233 (107.191.35.233) 119.045 ms 119.246 ms 119.466 ms
3 108.61.92.205 (108.61.92.205) 119.241 ms 120.030 ms 120.033 ms
4 66.55.144.145 (66.55.144.145) 145.257 ms 127.335 ms 145.301 ms
5 198.32.160.130 (198.32.160.130) 122.537 ms 72.14.214.16 (72.14.214.16) 122.541 ms 123.544 ms
6 209.85.246.223 (209.85.246.223) 123.656 ms 108.170.234.11 (108.170.234.11) 121.911 ms 216.239.63.95 (216.239.63.95) 119.989 ms
7 108.170.235.27 (108.170.235.27) 120.361 ms 108.170.235.21 (108.170.235.21) 120.443 ms 108.170.233.243 (108.170.233.243) 121.028 ms
8 8.8.8.8 (8.8.8.8) 120.421 ms 121.028 ms 121.029 ms
答案1
使用 VPN 时互联网连接的一个常见问题是域名解析。
最简单的解决方案是全局设置一个公共 DNS 服务器。可以通过输入以下内容来完成/etc/resolv.conf
:
nameserver 8.8.8.8