[已解决] pptpclient连接VPN

包含网卡/无线网的网络问题和ADSL/校园网/宽带拨号支持及代理/共享等网络使用问题
回复
yufw
帖子: 24
注册时间: 2014-05-19 12:26

[已解决] pptpclient连接VPN

#1

帖子 yufw »

我下载了pptpclient,连好了VPN,但是怎么让所有流量都走VPN呢?
当前的路由表是这样的,

代码: 全选

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    204    0        0 eno1
10.10.0.1       0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
173.255.216.225 192.168.1.1     255.255.255.255 UGH   0      0        0 eno1
192.168.1.0     0.0.0.0         255.255.255.0   U     204    0        0 eno1
173.255.216.225是VPN服务器的地址,192.168.1.1是默认网关地址。我试着修改路由表,

代码: 全选

$ ip route del default
ip route add default dev ppp0
现在路由表变成这样了,

代码: 全选

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         0.0.0.0         0.0.0.0         U     0      0        0 ppp0
10.10.0.1       0.0.0.0         255.255.255.255 UH    0      0        0 ppp0
173.255.216.225 192.168.1.1     255.255.255.255 UGH   0      0        0 eno1
192.168.1.0     0.0.0.0         255.255.255.0   U     204    0        0 eno1
看起来没有问题,可是我上不了网了,谁能告诉我到底是哪儿出错了呢?
上次由 yufw 在 2014-07-02 20:44,总共编辑 1 次。
taohunter
帖子: 1555
注册时间: 2012-03-31 3:29

Re: pptpclient连接VPN

#2

帖子 taohunter »

你用的不是ubuntu吧?Gentoo?你自己这台是服务器还是家用pc?你用的那个vpn是国内的还是国外的?是自己搭建的、公司内部的还是vpn服务商提供的?如果是服务商提供的,是否是免费的(或者收费但你已经支付)?--如果你提供的173.255.216.225是公网ip,这台服务器应该是在美国的提供hosting服务的linode.com的,如果是的话,估计就是你自己搭建的vnp服务器了?如果是这样你要检查一下自己的服务器搭建是否正确--既然你能用vpn客户端连上去,说明ip方式下这台vpn服务器本身到公网也是通的,那就看看你的服务器端类似route table/dns之类的配置是否正确吧。

先把以下命令的输出贴上来看一下:

代码: 全选

ifconfig
ping 173.255.216.225
ping 8.8.8.8
ping www.yahoo.com
ping www.sina.com.cn
三年后终于回到16.04--稳定了!
yufw
帖子: 24
注册时间: 2014-05-19 12:26

Re: pptpclient连接VPN

#3

帖子 yufw »

我用的是云梯的VPN服务,Windows下连接没有问题,可见服务器应该没有问题,我觉得问题应该处在pptpclient的设置上。

代码: 全选

$ ifconfig

代码: 全选

eno1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.101  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::9a4b:e1ff:feb8:30d8  prefixlen 64  scopeid 0x20<link>
        ether 98:4b:e1:b8:30:d8  txqueuelen 1000  (Ethernet)
        RX packets 5031  bytes 3871939 (3.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5499  bytes 767981 (749.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 1496
        inet 10.10.0.36  netmask 255.255.255.255  destination 10.10.0.1
        ppp  txqueuelen 3  (Point-to-Point Protocol)
        RX packets 295  bytes 46155 (45.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 412  bytes 45059 (44.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

sit0: flags=193<UP,RUNNING,NOARP>  mtu 1480
        inet6 ::127.0.0.1  prefixlen 96  scopeid 0x90<compat,host>
        sit  txqueuelen 0  (IPv6-in-IPv4)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlo1: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether ec:55:f9:19:95:3b  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

代码: 全选

$ ping 173.255.216.225
PING 173.255.216.225 (173.255.216.225) 56(84) bytes of data.
64 bytes from 173.255.216.225: icmp_seq=1 ttl=52 time=183 ms
64 bytes from 173.255.216.225: icmp_seq=3 ttl=52 time=182 ms

--- 173.255.216.225 ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2001ms
rtt min/avg/max/mdev = 182.477/183.052/183.628/0.717 ms

代码: 全选

$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=2 ttl=48 time=504 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=48 time=1503 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=48 time=235 ms

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 235.322/747.822/1503.831/545.741 ms, pipe 2

代码: 全选

$ ping www.yahoo.com
PING ds-any-fp3-real.wa1.b.yahoo.com (206.190.36.105) 56(84) bytes of data.
64 bytes from ir2.fp.vip.gq1.yahoo.com (206.190.36.105): icmp_seq=1 ttl=53 time=205 ms
64 bytes from ir2.fp.vip.gq1.yahoo.com (206.190.36.105): icmp_seq=2 ttl=53 time=206 ms
64 bytes from ir2.fp.vip.gq1.yahoo.com (206.190.36.105): icmp_seq=3 ttl=53 time=225 ms

--- ds-any-fp3-real.wa1.b.yahoo.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 205.808/212.638/225.964/9.438 ms

代码: 全选

$ ping www.sina.com.cn
PING ara.sina.com.cn (58.63.236.46) 56(84) bytes of data.
64 bytes from 58.63.236.46: icmp_seq=1 ttl=52 time=341 ms
64 bytes from 58.63.236.46: icmp_seq=2 ttl=52 time=341 ms
64 bytes from 58.63.236.46: icmp_seq=3 ttl=52 time=339 ms

--- ara.sina.com.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 339.388/340.620/341.473/1.011 ms
pptpclient配置文件如下,

代码: 全选

$ cat /etc/ppp/options
lock
noauth
nobsdcomp
nodeflate
refuse-pap
refuse-eap
refuse-chap
usepeerdns

代码: 全选

$ cat /etc/ppp/peers/ytvpn
pty "pptp us1.vpnko.com --nolaunchpppd"
name yufw
remotename ytvpn
ipparam ytvpn
require-mppe-128
file /etc/ppp/options
yufw
帖子: 24
注册时间: 2014-05-19 12:26

Re: pptpclient连接VPN

#4

帖子 yufw »

向/etc/ppp/peers/ytvpn添加如下两行就好了,

代码: 全选

mtu 1280
mru 1280
回复