Linux运行service iptables save报错

小咪咪 2022-05-22 07:59 356阅读 0赞

参考链接1:https://blog.csdn.net/song\_csdn1550/article/details/51768671

参考链接2: https://www.cnblogs.com/wanghuaijun/p/5469437.html

[root@tp ~]# service iptables save

The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

抛出以上异常提示信息:

在我自定义防火墙配置时,首先我清除了原配置信息

[root@tp ~]# iptables -F 清除预设表filter中的所有规则链的规则
[root@tp ~]# iptables -X 清除预设表filter中使用者自定链中的规则

然后查看iptable中的规则

[root@tp ~]# iptables -L -n

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)

target prot opt source destination

大致出现上面的输出则表明已经清除了原有的配置规则

因为上面的清除仅仅闲鱼当前启动情况,如果我们重启服务后,它又会回到原来的配置,所以我们需要持久保存

[root@tp ~]# service iptables save

在执行该语句的时候就出现了上面的报错信息,所以就有了下面的解决方案

执行一下命令:

[plain] view plain copy

  1. systemctl stop firewalld
  2. systemctl mask firewalld

并且安装iptables-services:

[plain] view plain copy

  1. yum install iptables-services

设置开机启动:

[plain] view plain copy

  1. systemctl enable iptables

[plain] view plain copy

  1. systemctl stop iptables
  2. systemctl start iptables
  3. systemctl restart iptables
  4. systemctl reload iptables

保存设置:

[plain] view plain copy

  1. service iptables save

这时候就可以了。

上面的操作是说把 firewalld 的防火墙关闭,并安装iptables形式的防火墙,然后设置开机时开启iptables形式的防火墙,然后为iptables载入start\stop

等操作指令。

使用下面的命令就可以操作iptables形式防火墙

service iptables status //查看防火墙状态
service iptables start //启动防火墙

service iptables stop //停止防火墙

service iptables restart //重启防火墙

Redirecting to /bin/systemctl restart iptables.service

在防火墙开启的情况,加载开放端口

开放某个端口 在/etc/sysconfig/iptables里添加

在该文件中找到

70

然后按照该格式修改端口就可以,然后重启iptables

发表评论

表情:
评论列表 (有 0 条评论,356人围观)

还没有评论,来说两句吧...

相关阅读