我在连接 VPN 时遇到了一个奇怪的问题。它把我踢出了互联网。
我已在“网络设置”中进行了设置(因为这是我能够使其工作的唯一方法)
现在,虽然我可以访问 VPN 上的网络文件(10.XXX 地址),也可以访问本地网络上的文件(192.XXX 地址),但我无法访问http://www.google.com或者在我的本地和 VPN 网络之外做任何事情。
我确实注意到有一个额外的图标显示 VPN 已连接,但还有另一个图标我认为是我的 LAN 图标,上面有一个 X。
我该怎么做?我需要能够连接到我的 VPN,并且仍具有外部访问权限?
路线 - 无 VPN 连接
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.2.2 0.0.0.0 UG 0 0 0 eth1
192.168.2.0 * 255.255.255.0 U 1 0 0 eth1
路线 - 使用 VPN 连接
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default * 0.0.0.0 U 0 0 0 ppp0
10.10.10.120 * 255.255.255.255 UH 0 0 0 ppp0
mail.emagineusa 192.168.2.2 255.255.255.255 UGH 0 0 0 eth1
mail.emagineusa 192.168.2.2 255.255.255.255 UGH 0 0 0 eth1
192.168.2.0 * 255.255.255.0 U 1 0 0 eth1
主机 - google.com
google.com has address 74.125.226.64
google.com has address 74.125.226.69
google.com has address 74.125.226.71
google.com has address 74.125.226.66
google.com has address 74.125.226.65
google.com has address 74.125.226.72
google.com has address 74.125.226.78
google.com has address 74.125.226.73
google.com has address 74.125.226.70
google.com has address 74.125.226.67
google.com has address 74.125.226.68
google.com has IPv6 address 2607:f8b0:4006:808::1006
google.com mail is handled by 30 alt2.aspmx.l.google.com.
google.com mail is handled by 20 alt1.aspmx.l.google.com.
google.com mail is handled by 40 alt3.aspmx.l.google.com.
google.com mail is handled by 10 aspmx.l.google.com.
google.com mail is handled by 50 alt4.aspmx.l.google.com.
跟踪路由至 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
1 10.10.10.120 (10.10.10.120) 46.576 ms 50.601 ms 51.521 ms
2 L300.BSTNMA-VFTTP-81.verizon-gni.net (98.110.197.1) 52.778 ms 53.686 ms 53.706 ms
3 G0-14-2-0.BSTNMA-LCR-21.verizon-gni.net (130.81.218.198) 56.615 ms 61.274 ms 62.174 ms
4 ae9-0.BOS-BB-RTR1.verizon-gni.net (130.81.163.164) 57.436 ms * *
5 * * *
6 * 0.xe-8-3-0.GW13.NYC1.ALTER.NET (152.63.5.1) 62.251 ms 0.xe-8-1-0.GW13.NYC1.ALTER.NET (152.63.4.133) 59.390 ms
7 204.148.18.206 (204.148.18.206) 63.106 ms 66.221 ms 63.127 ms
8 209.85.247.7 (209.85.247.7) 66.184 ms 67.259 ms 66.149 ms
9 72.14.236.206 (72.14.236.206) 62.044 ms 209.85.252.242 (209.85.252.242) 64.209 ms 209.85.252.250 (209.85.252.250) 65.193 ms
10 72.14.239.93 (72.14.239.93) 65.624 ms 209.85.249.11 (209.85.249.11) 68.308 ms 72.14.239.93 (72.14.239.93) 70.615 ms
11 66.249.95.229 (66.249.95.229) 78.416 ms 72.14.235.10 (72.14.235.10) 78.483 ms 64.233.174.11 (64.233.174.11) 77.413 ms
12 72.14.234.65 (72.14.234.65) 77.720 ms 78.676 ms 72.14.234.55 (72.14.234.55) 79.552 ms
13 google-public-dns-a.google.com (8.8.8.8) 74.189 ms 74.678 ms 75.782 ms
答案1
我只能建议您使用脚本通过 ppp0 接口将路由或主机添加到路由器流量...
试试也许会有效。创建带有名称的文件并输入
nano name_of_script
脚本
#!/bin/bash
function routeadd {
route add -host xxx.xxx.xxx.xxx dev ppp0
route add -net xxx.xxx.xxx.xxx/xx dev ppp0
}
function makepptp {
echo pty \"pptp xxx.xxx.xxx.xxx --nolaunchpppd\" >> /etc/ppp/peers/vpn;
echo remotename PPTP >> /etc/ppp/peers/vpn;
echo require-mppe-128 >> /etc/ppp/peers/vpn;
echo file /etc/ppp/options.pptp >> /etc/ppp/peers/vpn;
echo ipparam vpn >> /etc/ppp/peers/vpn;
pppd call vpn &
}
if [ -a /etc/ppp/chap-secrets ];
then
rm /etc/ppp/chap-secrets
echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
else
echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
fi
if [ -e /etc/ppp/peers/vpn ];
then
rm /etc/ppp/peers/vpn;
echo name $1 >> /etc/ppp/peers/vpn;
makepptp;
sleep 8;
routeadd;
else
echo name $1 >> /etc/ppp/peers/vpn;
makepptp;
sleep 8;
routeadd;
fi
在脚本中更改主机 IP 并添加您希望通过 VPN 连接的网络或/和主机
用法:
sudo /path_to_script/name_of_script username password
注意:设置脚本的执行权限
通过这种方式,你就可以控制流量。
编辑1
您想要通过 vpn 访问的服务器位于 10.10.10.10 您的 vpn 服务器位于 172.16.16.16
你将脚本改成如下形式
#!/bin/bash
function routeadd {
route add -host 10.10.10.10 dev ppp0
}
function makepptp {
echo pty \"pptp 172.16.16.16 --nolaunchpppd\" >> /etc/ppp/peers/vpn;
echo remotename PPTP >> /etc/ppp/peers/vpn;
echo require-mppe-128 >> /etc/ppp/peers/vpn;
echo file /etc/ppp/options.pptp >> /etc/ppp/peers/vpn;
echo ipparam vpn >> /etc/ppp/peers/vpn;
pppd call vpn &
}
if [ -a /etc/ppp/chap-secrets ];
then
rm /etc/ppp/chap-secrets
echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
else
echo $1 PPTP $2 '*' >> /etc/ppp/chap-secrets;
fi
if [ -e /etc/ppp/peers/vpn ];
then
rm /etc/ppp/peers/vpn;
echo name $1 >> /etc/ppp/peers/vpn;
makepptp;
sleep 8;
routeadd;
else
echo name $1 >> /etc/ppp/peers/vpn;
makepptp;
sleep 8;
routeadd;
fi