首先任意运行一条iptables防火墙规则配置命令如开通80端口: 2 q) y! ^% h+ I! y! ^
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
i% z# N: I- z+ `- A/ d x/ B( w
然后对iptables服务进行保存:
) X# C4 g, x9 b3 F z6 S7 i! g
service iptables save
+ {4 ?0 P$ j/ s' I/ K
如果失败报出: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. 4 Q" f/ o( y$ G; M' \% L
解决方法:7 @# Q, H3 ]' W) h8 K( m
systemctl stop firewalld 关闭防火墙 ; D3 i, f c5 n+ d
yum install iptables-services 安装或更新服务
6 D! m. ~; f+ B9 y再使用systemctl enable iptables 启动iptables
& b( S9 V+ Z: L5 ?0 H1 Z4 i最后 systemctl start iptables 打开iptables
' F7 b$ Q! c8 T) m
再执行service iptables save & ^4 U. X/ z3 c' ]* |3 U4 d
然后重启iptables服务: " u0 S; M; ~ A# b |; J! N
service iptables restart
$ E8 [7 ~+ u" H! L' m2 T/ V: q
执行完毕之后/etc/syscofig/iptables文件就有了
( E3 h" P! [/ @! d' f5 K& \4 x |