首页 > 技术文章 > mac使用pptp的正确方式

sctb 2020-03-31 00:07 原文

环境:macos mojave 10.14.6

尝试的解决方案:

  1. mac自带vpn 结论:已经不支持pptp协议

  2. 使用shimo 结论:无用,连接的时候没反应

  3. 为了解决不能连接的问题,某老外写的pptp连接工具 结论:无用,报错信息和下一步脚本执行结果一样

  4. 实用pppd,步骤如下:

    1)进入 /etc/ppp/peers/ 目录,创建 test.vpn,此文件名自己取;

    2)写入以下内容,根据需要修改;

    plugin PPTP.ppp
    noauth
    remoteaddress "------VPN server name or IP address------"
    user "------VPN username------"
    password "------VPN password------"
    redialcount 1
    redialtimer 5
    idle 1800
    # mru 1368
    # mtu 1368
    receive-all
    novj 0:0
    ipcp-accept-local
    ipcp-accept-remote
    refuse-eap
    refuse-pap
    refuse-chap-md5
    hide-password
    mppe-stateless
    mppe-128
    # require-mppe-128
    looplocal
    nodetach
    ms-dns 8.8.8.8
    usepeerdns
    # ipparam gwvpn
    defaultroute
    debug
    

    3)运行sudo pppd call test.vpn

    结论:出错,结果如下:

    Sat Feb 29 11:24:47 2020 : publish_entry SCDSet() failed: Success!
    Sat Feb 29 11:24:47 2020 : publish_entry SCDSet() failed: Success!
    Sat Feb 29 11:24:47 2020 : PPTP connecting to server 'xxx.xxx.xxx.xxx' (xxx.xxx.xxx.xxx)...
    Sat Feb 29 11:24:48 2020 : PPTP connection established.
    Sat Feb 29 11:24:48 2020 : PPTP set port-mapping for en0, interface: 9, protocol: 0, privatePort: 0
    Sat Feb 29 11:24:48 2020 : using link 0
    Sat Feb 29 11:24:48 2020 : Using interface ppp0
    Sat Feb 29 11:24:48 2020 : Connect: ppp0 <--> socket[34:17]
    Sat Feb 29 11:24:48 2020 : sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x60725c7f> ]
    Sat Feb 29 11:24:51 2020 : rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x90775e6> ]
    Sat Feb 29 11:24:51 2020 : lcp_reqci: returning CONFACK.
    Sat Feb 29 11:24:51 2020 : sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x90775e6> ]
    Sat Feb 29 11:24:51 2020 : sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x60725c7f> ]
    Sat Feb 29 11:24:51 2020 : rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x60725c7f> ]
    Sat Feb 29 11:24:51 2020 : rcvd [CHAP Challenge id=0xf9 <4a44a223bded3c174d9524e514b7b186>, name = "pptpd"]
    Sat Feb 29 11:24:51 2020 : sent [CHAP Response id=0xf9 <7fa23ba608c73e19030ab3ac356541de00000000000044442b41d5fa9f4034e4ba1cf873502c4e3e4ca4d86752c1994800>, name = "xx"]
    Sat Feb 29 11:24:51 2020 : rcvd [LCP ConfReq id=0x2 <asyncmap 0x0> <magic 0x241bc6d7> ]
    Sat Feb 29 11:24:51 2020 : sent [LCP ConfReq id=0x2 <asyncmap 0x0> <magic 0x330e8a78> ]
    Sat Feb 29 11:24:51 2020 : lcp_reqci: returning CONFACK.
    Sat Feb 29 11:24:51 2020 : sent [LCP ConfAck id=0x2 <asyncmap 0x0> <magic 0x241bc6d7> ]
    Sat Feb 29 11:24:51 2020 : rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x60725c7f> ]
    Sat Feb 29 11:24:51 2020 : rcvd [LCP ConfAck id=0x2 <asyncmap 0x0> <magic 0x330e8a78> ]
    Sat Feb 29 11:24:51 2020 : rcvd [CHAP Challenge id=0xf1 <7152e60444448f03c00d77bc4f4f85e7>, name = "pptpd"]
    Sat Feb 29 11:24:51 2020 : sent [CHAP Response id=0xf1 <67c6ba6d36b2fcf0f07d2b24d38a13db000000000000000099b744446dee24113587aab45c859bc033099f424d94e50400>, name = "xx"]
    Sat Feb 29 11:24:51 2020 : rcvd [CHAP Success id=0xf1 "S=21E481AFF77DB980039418F738D7749C6A4C590A M=Access granted"]
    Sat Feb 29 11:24:51 2020 : sent [CCP ConfReq id=0x1 <mppe +H -M +S -L -D -C>]
    Sat Feb 29 11:24:51 2020 : rcvd [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
    Sat Feb 29 11:24:51 2020 : MPPE required but peer negotiation failed
    Sat Feb 29 11:24:51 2020 : sent [LCP TermReq id=0x3 "MPPE required but peer negotiation failed"]
    Sat Feb 29 11:24:51 2020 : Connection terminated.
    Sat Feb 29 11:24:51 2020 : sent [CCP ConfRej id=0x1 <deflate 15> <deflate(old#) 15>]
    Sat Feb 29 11:24:51 2020 : PPTP disconnecting...
    Sat Feb 29 11:24:51 2020 : PPTP clearing port-mapping for en0
    Sat Feb 29 11:24:51 2020 : PPTP disconnected

    可以发现,报错信息在这里:

    MPPE required but peer negotiation failed

    多方搜索无果,只能靠自己了......

    再次打开 test.vpn 配置文件,我发现了其中关于 mmpe 的部分:

    mppe-stateless
    mppe-128
    # require-mppe-128
    

    发现问题所在了吗?我搜索到的所有教我配置pppd配置文件中的内容都是这样,但是报错却提示“MPPE required but peer negotiation failed”,因此,我尝试将另外两行和mmpe相关的配置行注释掉,结果如下:

    # mppe-stateless
    # mppe-128
    # require-mppe-128
    

    再次执行 sudo pppd call test.vpn,错误解决,运行成功!!

    如图,运行成功后,最下面两行是这样:

推荐阅读