第一范文网 - 专业文章范例文档资料分享平台

CentOS 5.6 安装L2TP VPN以及2种客户端连接方法

来源:用户分享 时间:2025/5/28 23:55:14 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

CentOS 5.6 安装L2TP VPN以及2种客户端连接方法

第二层隧道协议L2TP(Layer 2 Tunneling Protocol)是一种工业标准的Internet隧道协议,它使用UDP的1701端口进行通信。L2TP本身并没有任何加密,但是我们可以使用IPSec对L2TP包进行加密。L2TP VPN比PPTP VPN搭建复杂一些。 网络环境:

Eth0: 192.168.58.128/255.255.255.0 DNS:8.8.8.8 (可访问外网) Eth1:192.168.238.129(内网)

(vpn分配的IP网段)10.0.0.0/255.255.0.0

说明,我看了网上许多文档,深受其害。经历了个各种磨难,终于领悟了?以下省略N个字。如果相信我,请往下看。

关闭selinux setenforce 0

关闭防火墙

/etc/init.d/iptables stop

linux同步北京时间 ntpdate ntp.fudan.edu.cn

一、修改包转发设置

复制以下两段代码在终端里运行:

for each in /proc/sys/net/ipv4/conf/* do

echo 0 > $each/accept_redirects echo 0 > $each/send_redirects done

echo 1 >/proc/sys/net/core/xfrm_larval_drop

修改内核设置,使其支持转发,编辑/etc/sysctl.conf文件: vi /etc/sysctl.conf

将“net.ipv4.ip_forward”的值改为1。 使修改生效: sysctl -p

二、安装L2TP(xl2tpd和rp-l2tp)

xl2tpd是由Xelerance Corporation维护的l2tpd应用。但是xl2tpd没有l2tp-control,需要从rp-l2tp这个里面提取。所以要装这两个软件包。 1、安装必备软件:

yum install -y libpcap-devel ppp policycoreutils yum clean all

使用rpm 安装ppp pptpd

安装EPEL(企业级 Linux提供的扩展软件源) 如果是centos 5.x系列,请安装以下文件

rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

【如果是centos 6.x系列,请安装以下文件

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm vi /etc/yum.repos.d/epel.repo 将所有的https改成http yum clean all】 yum安装xl2tpd

yum install -y xl2tpd

2、xl2tpd配置文件: cd /etc/xl2tpd/

cp xl2tpd.conf xl2tpd.conf.bak vi xl2tpd.conf 修改红色字段:

注意local ip后面填写的IP地址不是外网地址,也不是内网地址,而是虚拟网关的IP地址

[lns default]

;最大有65533个客户端

ip range = 10.0.0.2-10.0.255.254 local ip = 10.0.0.1 require chap = yes refuse pap = yes

require authentication = yes name = LinuxVPNserver ppp debug = yes

pppoptfile = /etc/ppp/options.xl2tpd length bit = yes

3、配置ppp/options.xl2tpd文件: cd /etc/ppp/

cp options.xl2tpd options.xl2tpd.bak vi options.xl2tpd

删除所有内容,增加以下内容: require-mschap-v2 ms-dns 8.8.8.8 ms-dns 8.8.4.4 asyncmap 0 auth crtscts lock

hide-password modem debug

name xl2tpd proxyarp

lcp-echo-interval 30

lcp-echo-failure 4

4、设置拨号用户名和密码:

cp chap-secrets chap-secrets.bak vi chap-secrets

test表示用户名,xl2tpd表示服务类型,123表示密码,*表示允许所以IP地址连接

# Secrets for authentication using CHAP

# client server secret IP addresses

####### redhat-config-network will overwrite this part!!! (begin) ########## ####### redhat-config-network will overwrite this part!!! (end) ############ test xl2tpd 123 *

5、以debug方式启动l2tp,查看有无错误: xl2tpd -D 显示如下:

xl2tpd[3580]: setsockopt recvref[30]: Protocol not available xl2tpd[3580]: This binary does not support kernel L2TP.

xl2tpd[3580]: open_controlfd: Unable to open /var/run/xl2tpd/l2tp-control for reading. 出现以上错误时,需要手动建立xl2tpd目录 mkdir /var/run/xl2tpd 再次执行xl2tpd -D

xl2tpd[3617]: setsockopt recvref[30]: Protocol not available xl2tpd[3617]: This binary does not support kernel L2TP.

xl2tpd[3617]: open_controlfd: Unable to open /var/run/xl2tpd/l2tp-control for reading. [root@NBX1 ppp]# mkdir /var/run/xl2tpd [root@NBX1 ppp]# xl2tpd -D

xl2tpd[3619]: setsockopt recvref[30]: Protocol not available xl2tpd[3619]: This binary does not support kernel L2TP.

xl2tpd[3619]: xl2tpd version xl2tpd-1.3.1 started on NBX1.localdomain PID:3619 xl2tpd[3619]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc. xl2tpd[3619]: Forked by Scott Balmos and David Stipp, (C) 2001 xl2tpd[3619]: Inherited by Jeff McAdams, (C) 2002

xl2tpd[3619]: Forked again by Xelerance (www.xelerance.com) (C) 2006 xl2tpd[3619]: Listening on IP address 0.0.0.0, port 1701

说明已经在监听端口了。现在可以在windows上建立L2TP拨号连接了。 三、设置开机启动

chkconfig --level 3 xl2tpd on 启动xl2tp

/etc/init.d/xl2tpd start 查看监听端口

netstat -naptlu | grep xl2tpd

udp 0 0 0.0.0.0:1701 0.0.0.0:*

3671/xl2tpd

Linux L2TP客户端连接方法

关闭selinux setenforce 0

关闭防火墙

/etc/init.d/iptables stop

linux同步北京时间 ntpdate ntp.fudan.edu.cn

安装EPEL(企业级 Linux提供的扩展软件源) 如果是centos 5.x系列,请安装以下文件

rpm -ivh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 【如果是centos 6.x系列,请安装以下文件

rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm vi /etc/yum.repos.d/epel.repo 将所有的https改成http yum clean all】 安装xl2tpd

yum install -y xl2tpd

配置xl2tpd文件 cd /etc/xl2tpd/

cp xl2tpd.conf xl2tpd.conf.bak vi xl2tpd.conf

;VPN名称为testvpn [lac testvpn] ;l2tp帐号 name = test

; l2tp server的IP lns = 192.168.58.128

; pppd拨号时使用的配置文件

pppoptfile = /etc/ppp/peers/testvpn.l2tpd ppp debug = yes

设置拨号配置文件 cd /etc/ppp/peers/ vi testvpn.l2tpd

CentOS 5.6 安装L2TP VPN以及2种客户端连接方法.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3ucah1qx0u8mpoi7oh1o_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top