|
首先任意运行一条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
|