找回密码
 立即注册
查看: 4285|回复: 0

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

[复制链接]
发表于 2019-4-2 11:17:53 | 显示全部楼层 |阅读模式
首先任意运行一条iptables防火墙规则配置命令如开通80端口:
! u6 Q$ I& J, B7 Y4 f( d
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT

* a/ s2 D+ L1 a5 R, \8 l) t
然后对iptables服务进行保存:

1 c* G/ \* A5 x) \( g* y
service iptables save

# ]" \" H/ l8 D% B! i1 G
如果失败报出: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.
0 }. t( n" t$ a) h* T2 }3 [
解决方法:, F; ^! a' z0 F" b4 h/ f
systemctl stop firewalld 关闭防火墙

/ C: b% x' @2 [0 X' M' oyum install iptables-services 安装或更新服务
1 a: V- ]8 p4 K8 S6 w
再使用systemctl enable iptables 启动iptables
+ V* e( t8 H  k2 l2 ]  f- a1 W
最后 systemctl start iptables 打开iptables

3 J) s- ~7 Z) ^; `
再执行service iptables save
$ ~* ~& j) }4 |3 n$ P2 f0 g. P
然后重启iptables服务:
' @2 Z, |* L. C' p! P
service iptables restart
3 J2 C, E; D  t3 @0 e9 h
执行完毕之后/etc/syscofig/iptables文件就有了

1 c$ w  X' p/ m
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2024-3-29 17:48 , Processed in 0.064654 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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