找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 9234|回复: 0

centos7中没有service iptables save无效的解决方法

[复制链接]
发表于 2019-4-2 11:17:53 | 显示全部楼层 |阅读模式
首先任意运行一条iptables防火墙规则配置命令如开通80端口:
% P  T; e4 C4 j( L! o( j" y
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT

% C$ U  ~! q2 R2 P8 c
然后对iptables服务进行保存:

: q* n, j1 w: n
service iptables save

) N4 N$ g8 a2 o% e: d3 o/ Z
如果失败报出: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.
  D& w. d7 S+ }. ?5 _3 t
解决方法:8 K/ T& n% z# r+ y5 a' e
systemctl stop firewalld 关闭防火墙
9 I% }& T6 E$ M' N9 z
yum install iptables-services 安装或更新服务
9 ~/ q4 i2 Z1 x% ]. L. ?; }+ }
再使用systemctl enable iptables 启动iptables

& Q8 h& y" {& G- K最后 systemctl start iptables 打开iptables
9 ~( x8 C& u0 z9 Q8 k" l
再执行service iptables save

0 c/ g8 @, e+ z" f
然后重启iptables服务:

4 T' r* ^/ c. I
service iptables restart
: p- ^! o- z  Q9 m- V
执行完毕之后/etc/syscofig/iptables文件就有了
, j# Y0 m3 [, G
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|第一站论坛 ( 蜀ICP备06004864号-6 )

GMT+8, 2026-5-7 00:37 , Processed in 0.060457 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表