L2TP ××× 服务器搭建和使用

L2TP 服务器搭建和使用


1、安装脚本

下载脚本一键安装l2tp ***git

wget --no-check-certificate https://raw.githubusercontent.com/teddysun/across/master/l2tp.sh github

chmod +x l2tp.sh //添加可执行权限centos

. l2tp.sh 执行脚本 若是非root用户使用su sh安全

根据提示进行安装服务器

2、服务器启动命令

启动服务网络

service ipsec start 编辑器

service xl2tpd start ide

中止服务centos7

service ipsec stoprest

service xl2tpd stop

重启服务

service ipsec restart

service xl2tpd restart

分析ipsec的状态

ipsec verify

查看服务是否启动成功

[root@centos7 download]# ps -ef | grep -E "(ipsec|l2tp)" 
root      4164     1  0 17:32 ?        00:00:00 /usr/sbin/xl2tpd -D
root      4461     1  0 17:32 ?        00:00:00 /usr/libexec/ipsec/pluto --leak-detective --config /etc/ipsec.conf --nofork
root      4513  3692  0 17:40 pts/4    00:00:00 grep --color=auto -E (ipsec|l2tp)

将启动命令写入到/etc/rc.local中,并查看/etc/rc.local是否为连接文件,若是没法执行须要检查源文件是否有执行权限,用chomod +x添加执行权限。添加完命令以后,服务器每次开机才会自动执行脚本命令将所需的服务开启。

3、管理帐号

修改/etc/ppp/chap-secrets文件

[root@centos7 ~]# cat /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client    server    secret    IP addresses
jacky    l2tpd    yourpassword       *

**

4、调整网络参数

修改 /etc/sysctl.conf 文件开启路由功能, vi /etc/sysctl.conf

将下面两项找到:

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

改成:

net.ipv4.ip_forward = 1

net.ipv4.conf.default.rp_filter = 0

以后先让修改后的配置生效,
sysctl -p

iptables修改

root@centos7 ~]# iptables -t nat -A POSTROUTING -s 192.168.17.0/24 -o eth0 -j MASQUERADE
[root@centos7 ~]# iptables -I FORWARD -s 192.168.17.0/24 -j ACCEPT
[root@centos7 ~]# iptables -I FORWARD -d 192.168.17.0/24 -j ACCEPT
[root@centos7 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             192.168.17.0/24     
ACCEPT     all  --  192.168.17.0/24      anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

将Iptables修改添加到配置文件中,/etc/rc.d/init.d/iptables

CentOS7默认没有这个文件,能够将iptables命令写到/etc/rc.local中开机执行。

UDP 500,1701是L2TP的默认通讯端口,须要在防火墙,安全组策略这些地方容许其经过。

5、终端链接

支持的终端

win7+win10自带***客户端,andriod自带***客户端等

链接问题解决

一、win10系统 L2TP链接尝试失败:ERROR由于安全层在初始化与远程计算机的协商时遇到了一个处理错误

(1)建立 AllowL2TPWeakCrypto 注册表项,并将其设置为 1 的值。

1. 单击开始,单击运行,键入regedit,而后单击肯定
    2. 在注册表编辑器中,找到并单击如下注册表子项︰

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rasman\Parameters

3. 在编辑菜单上,指向新建,而后单击DWORD 值。
    4. 键入AllowL2TPWeakCrypto,而后按 enter 键。
    5. 在编辑菜单上,单击修改。
    6. 在数值数据框中,键入1,而后单击肯定。
    7. 在文件菜单上,单击退出以退出注册表编辑器。

(2)ProhibitIpSec 注册表项,并将其设置为 0 的值
1.定位注册表HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Rasman\Parameters

  1. 在“编辑”菜单上,单击“新建”->“DWORD值”
  2. 在“名称”框中,键入“ProhibitIpSec”
  3. 在“数值数据”框中,键入“1”,而后单击“肯定”
    (ps: “ProhibitIpSec”=dword:00000000 ;使用RAS的L2TP功能[1=关闭])

重启服务:IPsec Policy Agent,Routing and Remote Access,Remote Access Connection Manager

二、L2TP 809错误,win10提示l2tp被防火墙等设备不容许经过

有三个服务须要启动(“Remote Access Auto Connection Manager”、“Remote Access Connection Manager”和“Secure Socket Tunneling Protocol Service”),“Remote Access Auto Connection Manager”服务是手动的,若是未启动,改为自动启动并启动之,后再链接L2TP/IPSec的×××

相关文章
相关标签/搜索