centos 快速部署L2TP服务

在CentOS上快速部署l2tp服务

  1. 安装必要的工具
    yum install vim net-tools wget unzip -y
  2. 下载安装脚本,下载地址是http://files.cnblogs.com/files/think8848/StackScript.zip
    wget -O StackScript.zip http://files.cnblogs.com/files/think8848/StackScript.zip
  3. 解压文件
    unzip StackScript.zip
  4. 执行安装文件
    chmod +x StackScript
    ./StackScript
    脚本运行完,会显示密钥,用户名和密码以及服务器ip地址。这些都是笔者在里面写好的,可以根据自己的需求修改。

a. 先修改PSK,将PSK后面的字符替换掉

vim /etc/ipsec.secrets

b. 修改用户名和密码 ,将用户名和密码修改为自已想要的字符

vim /etc/ppp/chap-secrets

c. 重启IPsec和xl2tpd服务

systemctl restart ipsec xl2tpd

d. 将客户端的PSK、用户名、密码换成新的再连,应该就能上了。

注意如果开启了防火墙,需要在防火墙里面放行l2tp端口。

iptables -I INPUT -p tcp --dport 500 -j ACCEPT
iptables -I INPUT -p tcp --dport 4500 -j ACCEPT
iptables -I INPUT -p tcp --dport 1701 -j ACCEPT
/etc/init.d/iptables save
/etc/init.d/iptables restart

如若脚本地址有变化,可以编辑如下脚本运行即可
部署脚本
#!/bin/bash

#<UDF name="×××_IPSEC_PSK" Label="IPsec Pre-Shared Key" />
#<UDF name="×××_USER" Label="××× Username" />
#<UDF name="×××_PASSWORD" Label="××× Password" />

if [ -f /etc/apt/sources.list ]; then
url=setup
apt-get -y update
apt-get -y install wget
elif [ -f /etc/yum.conf ]; then
url=
setup-centos
yum -y install wget
else
echo "Your distribution is not supported by this StackScript"
exit 1
fi

wget "https://git.io/$url" -O /tmp/.sh && sh /tmp/.sh && rm -f /tmp/***.sh

#Fix xl2tpd on CentOS 7 for Linode VMs, because kernel module
#l2tp_ppp is not available in the default Linode kernel
if grep -qs "release 7" /etc/redhat-release; then
if [ -f /usr/lib/systemd/system/xl2tpd.service ]; then
sed -i '/ExecStartPre/s/^/#/' /usr/lib/systemd/system/xl2tpd.service
systemctl daemon-reload
systemctl restart xl2tpd
fi
fi

转载于:https://blog.51cto.com/907832555/2320503

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值