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