|
首先任意运行一条iptables防火墙规则配置命令如开通80端口: 2 \0 |& \4 m7 B Z3 z1 y/ f, ~( Y ^# E
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
2 `; r% v. ]1 Z8 A' q5 |. B
然后对iptables服务进行保存: / j1 ?1 L7 @6 Y( N* u
service iptables save
7 a6 ^+ N4 {0 v9 k- R
如果失败报出: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. " }. O* I6 b& n: P, v, s2 `( B
解决方法:
% W0 q+ v& K) z& B' y8 ]' {systemctl stop firewalld 关闭防火墙
: T7 v' U# @4 m/ U: kyum install iptables-services 安装或更新服务
. D0 e6 A; x2 `- n) T3 i
再使用systemctl enable iptables 启动iptables
, \4 z$ j7 V. U7 R7 d) U1 l2 |1 c最后 systemctl start iptables 打开iptables
$ e0 F8 L1 a7 w
再执行service iptables save
- R9 T m* C1 t- E+ C$ b. m7 N
然后重启iptables服务:
; n5 \3 \& g. I; I' K
service iptables restart : r) u- z/ v9 t2 ?: N
执行完毕之后/etc/syscofig/iptables文件就有了 6 y/ F' f5 t. C. @
|