setup-ipsec-vpn/docs/uninstall-zh.md
2022-05-08 08:33:09 -05:00

4.2 KiB
Raw Blame History

卸载 VPN

其他语言版本: English, 简体中文

使用辅助脚本卸载 VPN

警告:辅助脚本将从你的服务器中删除 IPsec VPN。所有的 VPN 配置将被永久删除,并且 Libreswan 和 xl2tpd 将被移除。此操作不可撤销

wget -nv -O vpnunst.sh https://get.vpnsetup.net/unst
sudo bash vpnunst.sh
如果无法下载,请点这里。

如果无法下载,点这里查看脚本。按快捷键 Ctrl/Cmd+A 全选,Ctrl/Cmd+C 复制,然后粘贴到你喜欢的编辑器。

手动卸载 VPN

另外,你也可以手动卸载 VPN。按照以下步骤操作。这些命令需要用 root 账户运行,或者使用 sudo

警告: 以下步骤将从你的服务器中删除 IPsec VPN。所有的 VPN 配置将被永久删除,并且 Libreswan 和 xl2tpd 将被移除。此操作不可撤销

步骤

第一步

service ipsec stop
service xl2tpd stop
rm -rf /usr/local/sbin/ipsec /usr/local/libexec/ipsec /usr/local/share/doc/libreswan
rm -f /etc/init/ipsec.conf /lib/systemd/system/ipsec.service /etc/init.d/ipsec \
      /usr/lib/systemd/system/ipsec.service /etc/logrotate.d/libreswan \
      /usr/lib/tmpfiles.d/libreswan.conf

第二步

Ubuntu & Debian

apt-get purge xl2tpd

CentOS/RHEL, Rocky Linux, AlmaLinux, Oracle Linux & Amazon Linux 2

yum remove xl2tpd

Alpine Linux

apk del xl2tpd

第三步

Ubuntu, Debian & Alpine Linux

编辑 /etc/iptables.rules 并删除不需要的规则。你之前的防火墙规则(如果有)备份在 /etc/iptables.rules.old-日期-时间。另外如果文件 /etc/iptables/rules.v4 存在,请编辑它。

CentOS/RHEL, Rocky Linux, AlmaLinux, Oracle Linux & Amazon Linux 2

编辑 /etc/sysconfig/iptables 并删除不需要的规则。你之前的防火墙规则(如果有)备份在 /etc/sysconfig/iptables.old-日期-时间

注: 如果使用 Rocky Linux, AlmaLinux, Oracle Linux 8 或者 CentOS/RHEL 8 并且在安装 VPN 时 firewalld 正在运行,则可能已配置 nftables。编辑 /etc/sysconfig/nftables.conf 并删除不需要的规则。你之前的防火墙规则备份在 /etc/sysconfig/nftables.conf.old-日期-时间

第四步

编辑 /etc/sysctl.conf 并删除该标记后面的行: # Added by hwdsl2 VPN script
编辑 /etc/rc.local 并删除该标记后面的行: # Added by hwdsl2 VPN script。*不要* 删除 exit 0 (如果有)。

可选步骤

注: 这一步是可选的。

删除这些配置文件:

  • /etc/ipsec.conf*
  • /etc/ipsec.secrets*
  • /etc/ppp/chap-secrets*
  • /etc/ppp/options.xl2tpd*
  • /etc/pam.d/pluto
  • /etc/sysconfig/pluto
  • /etc/default/pluto
  • /etc/ipsec.d (目录)
  • /etc/xl2tpd (目录)

要快速删除,可以复制并粘贴以下命令:

rm -f /etc/ipsec.conf* /etc/ipsec.secrets* /etc/ppp/chap-secrets* /etc/ppp/options.xl2tpd* \
      /etc/pam.d/pluto /etc/sysconfig/pluto /etc/default/pluto
rm -rf /etc/ipsec.d /etc/xl2tpd

删除 IKEv2 脚本:

rm -f /usr/bin/ikev2.sh /opt/src/ikev2.sh

完成后

重启你的服务器。

授权协议

版权所有 (C) 2016-2022 Lin Song View my profile on LinkedIn

Creative Commons License
这个项目是以 知识共享署名-相同方式共享3.0 许可协议授权。
必须署名: 请包括我的名字在任何衍生产品,并且让我知道你是如何改善它的!