CentOS 6.x 快速安装L2TP ***

一、简介

    L2TP是一种工业标准的Internet隧道协议,功能大致和PPTP协议类似,比如同样可以对网络数据流进行加密。不过也有不同之处,比如PPTP要求网络为IP网络,L2TP要求面向数据包的点对点连接;PPTP使用单一隧道,L2TP使用多隧道;L2TP提供包头压缩、隧道验证,而PPTP不支持。

    L2TP 是一个数据链路层协议。其报文分为数据消息和控制消息两类。数据消息用投递 PPP 帧,该帧作为L2TP报文的数据区。L2TP不保证数据消息的可靠投递,若数据报文丢失,不予重传,不支持对数据消息的流量控制和拥塞控制。控制消息用以建立、维护和终止控制连接及会话,L2TP确保其可靠投递,并支持对控制消息的流量控制和拥塞控制。

二、L2TP与PPTP的不同

    PPTP和L2TP都使用PPP协议对数据进行封装,然后添加附加包头用于数据在互联网络上的传输。尽管两个协议非常相似,但是仍存在以下几方面的不同:

  • PPTP要求互联网络为IP网络。L2TP只要求隧道媒介提供面向数据包的点对点的连接。L2TP可以在IP(使用UDP),帧中继永久虚拟电路(PVCs),X.25虚拟电路(VCs)或ATM VCs网络上使用。

  • PPTP只能在两端点间建立单一隧道。L2TP支持在两端点间使用多隧道。使用L2TP,用户可以针对不同的服务质量创建不同的隧道。

  • L2TP可以提供包头压缩。当压缩包头时,系统开销(overhead)占用4个字节,而PPTP协议下要占用6个字节。

  • L2TP可以提供隧道验证,而PPTP则不支持隧道验证。但是当L2TP或PPTP与IPSEC共同使用时,可以由IPSEC提供隧道验证,不需要在第2层协议上验证隧道

  • L2TP访问集中器(L2TP Access Concentrator,LAC)是一种附属在网络上的具有PPP端系统和L2Tpv2协议处理能力的设备,它一般就是一个网络接入服务器软件,在远程客户端完成网络接入服务的功能。

  • L2TP网络服务器(L2TP Network Server,LNS)是用于处理L2TP协议服务器端的软件。

三、L2TP的安装

1、环境准备

#安装epel源
rpm -ivh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm
#关闭防火墙
service iptables stop
#关闭SELinux
setenforce 0
#开启数据包转发
sysctl -w net.ipv4.ip_forward=1

2、软件安装

yum install xl2tpd -y

四、L2TP的配置

1、配置xl2tpd.conf主配置文件

# vim /etc/xl2tpd/xl2tpd.conf

[lns default]
ip range = 10.8.0.100-200            #***客户的分配的IP地址
local ip = 10.8.0.1                  #L2TP ***服务器的地址
require chap = yes
refuse pap = yes
require authentication = yes
name = L2TP***server
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes

2、配置options.xl2tpd文件

# vim /etc/ppp/options.xl2tpd

ipcp-accept-local
ipcp-accept-remote
ms-dns  114.114.114.114
# ms-dns  192.168.1.1
# ms-dns  192.168.1.3
# ms-wins 192.168.1.2
# ms-wins 192.168.1.4
noccp
auth
crtscts
idle 1800
mtu 1410
mru 1410
nodefaultroute
debug
lock
proxyarp
connect-delay 5000
logfile /var/log/xl2tpd.log

3、配置账号密码

# vim /etc/ppp/chap-secrets

# Secrets for authentication using CHAP
# client      server    secret    IP addresses
  ***           *       123456           *

4、配置IP映射

iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

五、L2TP启动

service xl2tpd start

# netstat -antup

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address     Foreign Address     State   PID/Program name   
tcp        0      0 0.0.0.0:22        0.0.0.0:*           LISTEN      1026/sshd           
tcp        0      0 127.0.0.1:25      0.0.0.0:*           LISTEN      1114/master         
tcp        0     52 192.168.1.10:22   192.168.1.36:62256  ESTABLISHED 1733/sshd           
udp        0      0 0.0.0.0:1701      0.0.0.0:*                       2378/xl2tpd

# 链接查看日志

# tail -f /var/log/message

Jan 17 14:25:21 node1 xl2tpd[2373]: L2TP kernel support not detected (try modprobing l2tp_ppp and pppol2tp)

Jan 17 14:25:21 node1 xl2tpd[2378]: xl2tpd version xl2tpd-1.3.6 started on node1.wzlinux.com PID:2378

Jan 17 14:25:21 node1 xl2tpd[2378]: Written by Mark Spencer, Copyright (C) 1998, Adtran, Inc.

Jan 17 14:25:21 node1 xl2tpd[2378]: Forked by Scott Balmos and David Stipp, (C) 2001

Jan 17 14:25:21 node1 xl2tpd[2378]: Inherited by Jeff McAdams, (C) 2002

Jan 17 14:25:21 node1 xl2tpd[2378]: Forked again by Xelerance (www.xelerance.com) (C) 2006

Jan 17 14:25:21 node1 xl2tpd[2378]: Listening on IP address 0.0.0.0, port 1701

Jan 17 14:27:29 node1 xl2tpd[2378]: Connection established to 192.168.1.36, 1701.  Local: 345, Remote: 1 (ref=0/0).  LNS session is 'default'

Jan 17 14:27:29 node1 xl2tpd[2378]: Call established with 192.168.1.36, Local: 51894, Remote: 1, Serial: 0

Jan 17 14:27:29 node1 pppd[2399]: pppd 2.4.5 started by root, uid 0

Jan 17 14:27:29 node1 pppd[2399]: Using interface ppp0

Jan 17 14:27:29 node1 pppd[2399]: Connect: ppp0 <--> /dev/pts/1

Jan 17 14:27:31 node1 pppd[2399]: Cannot determine ethernet address for proxy ARP

Jan 17 14:27:31 node1 pppd[2399]: local  IP address 10.8.0.1

Jan 17 14:27:31 node1 pppd[2399]: remote IP address 10.8.0.100





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值