脚本信息
#!/bin/bash
# Install necessary packages
dnf install -y xl2tpd ppp
# Get the local IP address of the machine
IP=$(hostname -I | awk {print $1} )
# Prompt for the shared secret
read -p "Enter the shared secret for L2TP connection: " SECRET
# Configure xl2tpd.conf
cat > /etc/xl2tpd/xl2tpd.conf << EOF
[global]
listen-addr = $IP
ipsec saref = no
[lns default]
ip range = 192.168.10.2-192.168.10.255
local ip = 192.168.10.1
refuse pap = yes
require authentication = yes
name = L2TPDVPN
ppp debug = yes
pppoptfile = /etc/ppp/options.xl2tpd
length bit = yes
EOF
# Configure options.xl2tpd
cat > /etc/ppp/options.xl2tpd << EOF
ipcp-accept-local
ipcp-accept-remote
refuse-eap
require-mschap-v2
noccp
noauth
idle 1800
mtu 1410
mru 1410
defaultroute
usepeerdns
debug
lock
connect-delay 5000
EOF
# Configure chap-secrets file and prompt for username and password
read -p "Enter username for VPN connection: " USERNAME
read -p "Enter password for VPN connection: " PASSWORD
echo "$USERNAME * $PASSWORD *" > /etc/ppp/chap-secrets
# Restart services
systemctl restart xl2tpd
systemctl enable xl2tpd
# Display connection information
echo "VPN connection information:"
echo "Server IP: $IP"
echo "Username: $USERNAME"
echo "Password: $PASSWORD"
echo "Shared Secret: $SECRET"
echo "Note: Use L2TPDVPN as the name of the VPN connection on the client."
使用方法:
- 复制以上脚本到一个文本编辑器中,将其保存为 l2tp-install.sh
- 打开终端并执行 chmod +x l2tp-install.sh 以使其可执行
chmod +x l2tp-install.sh
- 运行脚本 sudo ./l2tp-install.sh,按照提示输入共享密钥、用户名和密码等信息。
sudo ./l2tp-install.sh
- 配置完成后,您将看到 L2TP 连接的详细信息,包括服务器 IP 地址、用户名、密码和共享密钥。
- 请注意,在运行此脚本之前,最好备份任何现有的 L2TP 配置文件,以避免数据丢失。
您可以使用以下命令来检查xl2tpd服务是否正在运行,并查看其详细状态:
systemctl status xl2tpd
如果服务正在运行,则会显示如下类似输出:
● xl2tpd.service - Level 2 Tunnel Protocol Daemon (L2TP)
Loaded: loaded (/usr/lib/systemd/system/xl2tpd.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2023-03-28 10:28:13 UTC; 2h 47min ago
Main PID: 15551 (xl2tpd)
Tasks: 1 (limit: 11443)
Memory: 460.0K
CGroup: /system.slice/xl2tpd.service
└─15551 /usr/sbin/xl2tpd -D -c /etc/xl2tpd/xl2tpd.conf
Mar 28 10:28:13 server systemd[1]: Starting Level 2 Tunnel Protocol Daemon (L2TP)...
Mar 28 10:28:13 server systemd[1]: Started Level 2 Tunnel Protocol Daemon (L2TP).
您可以查看Active行,如果状态显示为active (running),则服务正在运行。如果您需要查看更多详细信息,请查看日志文件:/var/log/messages或/var/log/syslog。
windows 连接这个rocky linx 报错:在连接完成前,连接被远程计算机终止
- 进入“控制面板”-“网络和共享中心”-“更改适配器设置”
- 右键点“vvv连接”-“属性”-“安全”
- 选择“允许使用这些协议”,以下选项全部打勾即可:
“未加密的密码”
“质询握手身份验证协议”
“Microsoft CH****A****P Ve****rsion2”
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...


