flagify-com/OctoMation

现在一安装firewalld 所有端口就关闭了 服务器都上不去

wuzhi-dev opened this issue · 2 comments

现在一安装firewalld 所有端口就关闭了 服务器都上不去

请试试以下执行,将22端口提前到到防火墙

firewalld 停止后执行:

  1. 离线模式打开22端口
    firewall-offline-cmd --direct --add-rule ipv4 filter INPUT 0 -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT

  2. 延迟5分钟重启系统,避免防火墙不让连ssh时自动重启系统

shutdown -r +5 "Enabling firewall. If access is lost, server will restart in 2 minutes."

3.启动防火墙

systemctl start firewalld

  1. 测试是否可以连接ssh

  2. 第4步没有问题的话,取消第二步的系统重启
    shutdown -c

  3. 配置自启动防火墙,并将firewall-offline-cmd策略刷到持久策略中
    systemctl enable firewalld
    firewall-cmd --runtime-to-permanent

研究了一下 系统自带的ufw防火墙先关闭了 就不会这样了