AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1016983
Accepted
Kalib Zen
Kalib Zen
Asked: 2020-05-14 07:54:24 +0800 CST2020-05-14 07:54:24 +0800 CST 2020-05-14 07:54:24 +0800 CST

运行 iptables-restore 后无法访问我的服务器。如何还原此命令

  • 772

我决定运行这个命令

iptables-save | tee iptables_backup.conf | grep -v '\-A'

但是我不小心放了一个额外的命令 iptables-restore 并运行了它,现在我的服务器被锁定了。我不能再 SSH:

iptables-save | tee iptables_backup.conf | grep -v '\-A' | iptables-restore

我可以从救援磁盘访问我的服务器并查看所有文件,但是如何恢复上述命令来启动我的服务器?

我正在使用 Centos 8。

iptables centos8
  • 2 2 个回答
  • 92 Views

2 个回答

  • Voted
  1. Gerard H. Pille
    2020-05-18T00:29:18+08:002020-05-18T00:29:18+08:00

    聪明的你采取备份。为什么不使用它?

    iptables-restore < iptables_backup.conf
    
    • 1
  2. Best Answer
    Kalib Zen
    2020-05-18T00:42:29+08:002020-05-18T00:42:29+08:00

    由于备份没有用,因为它不包含 ipv6,所以我应该像这样为 ipv6 做另一个备份:

    ip6tables-save
    

    我通过在启动时使用 rc.local 将 iptables 恢复到原始状态来解决它。因此,在启动恢复时,我编辑了这个文件:

    nano /etc/rc.d/rc.local
    
    # Temporary commands to run once at startup to reset iptables to original state
    iptables -F
    iptables -X
    iptables -t nat -F
    iptables -t nat -X
    iptables -t mangle -F
    iptables -t mangle -X
    iptables -P INPUT ACCEPT
    iptables -P FORWARD ACCEPT
    iptables -P OUTPUT ACCEPT
    
    ip6tables -F
    ip6tables -X
    ip6tables -t nat -F
    ip6tables -t nat -X
    ip6tables -t mangle -F
    ip6tables -t mangle -X
    ip6tables -P INPUT ACCEPT
    ip6tables -P FORWARD ACCEPT
    ip6tables -P OUTPUT ACCEPT
    
    #chmod +x rc.local
    

    然后,我重新启动了系统。上面的脚本将运行,现在我可以访问我的服务器了。

    一切正常后,我删除了上述所有命令,以防止第二次再次自动运行。

    • 0

相关问题

  • OpenVPN 的 Linux IP 转发 - 正确的防火墙设置?

  • iptables 单个规则中的多个源 IP

  • 存储 iptables 规则的规范方法是什么

  • 使用 iptables 和 dhcpd 进行端口转发

  • 根据 Apache 日志数据自动修改 iptables 以阻止行为不良的客户端

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve