centos 快速部署L2TP服務

在CentOS上快速部署l2tp服務node

  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後面的字符替換掉git

vim /etc/ipsec.secretsvim

b. 修改用戶名和密碼 ,將用戶名和密碼修改成自已想要的字符centos

vim /etc/ppp/chap-secretsbash

c. 重啓IPsec和xl2tpd服務服務器

systemctl restart ipsec xl2tpdtcp

d. 將客戶端的PSK、用戶名、密碼換成新的再連,應該就能上了。ide

注意若是開啓了防火牆,須要在防火牆裏面放行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 restartthis

如若腳本地址有變化,能夠編輯以下腳本運行便可
部署腳本
#!/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 kernelif grep -qs "release 7" /etc/redhat-release; thenif [ -f /usr/lib/systemd/system/xl2tpd.service ]; thensed -i '/ExecStartPre/s/^/#/' /usr/lib/systemd/system/xl2tpd.servicesystemctl daemon-reloadsystemctl restart xl2tpdfifi

相關文章
相關標籤/搜索