|
首先任意运行一条iptables防火墙规则配置命令如开通80端口:
2 p7 T3 s1 o' o) Z0 o" O2 l
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
R" Q% T5 M, i
然后对iptables服务进行保存:
, j) }1 k- H* F, D( b g9 p; L
service iptables save : g* Z3 F* j# A: _4 C
如果失败报出: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. + `; C+ }+ J! @2 ~! c g
解决方法:
/ W) z2 E3 c0 A1 vsystemctl stop firewalld 关闭防火墙 6 W/ g0 |) F$ s
yum install iptables-services 安装或更新服务
3 S) O1 ]5 h# a. o" d. t# |6 O再使用systemctl enable iptables 启动iptables
. W/ U' U! F& n! {+ |' G' a
最后 systemctl start iptables 打开iptables
. S; T! x- X A% m
再执行service iptables save 6 r$ d* a' L9 [7 n0 D3 n T V: s2 O
然后重启iptables服务: * g1 O6 G) b3 f5 P. A+ p
service iptables restart 2 D; @8 Q2 T3 A p' j
执行完毕之后/etc/syscofig/iptables文件就有了 9 j5 w( @% y: c3 q! u6 @; ]9 h
|