下载脚本一键安装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安全
根据提示进行安装服务器
启动服务网络
service ipsec start
编辑器
service xl2tpd start
ide
中止服务centos7
service ipsec stop
rest
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添加执行权限。添加完命令以后,服务器每次开机才会自动执行脚本命令将所需的服务开启。
修改/etc/ppp/chap-secrets文件
[root@centos7 ~]# cat /etc/ppp/chap-secrets # Secrets for authentication using CHAP # client server secret IP addresses jacky l2tpd yourpassword *
**
修改 /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的默认通讯端口,须要在防火墙,安全组策略这些地方容许其经过。
win7+win10自带***客户端,andriod自带***客户端等
(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
重启服务:IPsec Policy Agent,Routing and Remote Access,Remote Access Connection Manager
有三个服务须要启动(“Remote Access Auto Connection Manager”、“Remote Access Connection Manager”和“Secure Socket Tunneling Protocol Service”),“Remote Access Auto Connection Manager”服务是手动的,若是未启动,改为自动启动并启动之,后再链接L2TP/IPSec的×××