在 CentOS 7 中设置 VPN 客户端连接

在 CentOS 7 中设置 VPN 客户端连接

我必须从客户端远程连接CentOSVPN托管在的服务器Windows

已完成的工作:

  1. 已安装的软件包yum 安装 ppp pptp

  2. 内容/etc/ppp/peers/harkiv_vpn

    # pty "pptp xxx.xxx.xxx.xxx --nolaunchpppd" # using IP address
    pty "pptp vpn.campus.harkiv.ua --nolaunchpppd"
    lock
    noauth
    nobsdcomp
    nodeflate
    nodefaultroute
    usepeerdns
    name user_name
    remotename harkiv_vpn
    ipparam harkiv_vpn
    refuse-pap
    refuse-eap
    refuse-chap
    refuse-mschap
    require-mppe
    nomppe-stateful
    
  3. 内容 /etc/ppp/chap-秘密

    # Secrets for authentication using CHAP
    # client server secret IP addresses
    
    user_name harkiv_vpn "user_password_in_dblquotes" *
    
  4. 创建脚本启动vpn1.sh

    systemctl stop firewalld            # stop the firewall
    pppd call harkiv_vpn                # start VPN connection
    # pppd call megarvpn debug nodetach # for starting VPN manually
    
  5. 创建脚本停止VPN

    pkill pptp                # stop VPN connection
    systemctl start firewalld # start the firewall
    systemctl restart network # restarting service recreates the file resolv.conf
    

连接启动后vpn,我仍然无法访问远程资源。我错过了什么?

答案1

运行脚本后启动vpn1.sh,VPN 连接已启动,但其中的网关取自当前网络连接,而不是远程 VPN 服务器。要更正此问题:

  1. 内容/etc/resolv.conf

    # Generated by NetworkManager
    search harkiv.local
    nameserver zzz.zzz.zzz.zzz # Remote VPN server gateway <- add this line
    nameserver xxx.xxx.xxx.xxx # DNS1 of network connection
    nameserver yyy.yyy.yyy.yyy # DNS2 of network connection
    
  2. 创建脚本启动vpn2.sh

    cp resolv.conf /etc/
    route add -net 10.0.0.0 netmask 255.0.0.0 gw zzz.zzz.zzz.zzz
    

相关内容