|
首先任意运行一条iptables防火墙规则配置命令如开通80端口: ! G3 L+ S; X. @0 M2 u
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT 3 N# Y1 h9 M: q% ^$ p$ X+ F3 k" l
然后对iptables服务进行保存: 6 r2 {( R) u$ e4 l" i) L/ E. y9 N; _
service iptables save ' r4 _6 t& D' w& N# ^
如果失败报出: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. / }8 m% W" |4 e. H. D
解决方法:
+ L/ B2 x; J5 O$ S, N7 Z) ysystemctl stop firewalld 关闭防火墙 . H2 x- @8 M, F
yum install iptables-services 安装或更新服务
2 D% Q; Y+ X2 j9 A! Q7 Q$ U再使用systemctl enable iptables 启动iptables
4 B; t/ b* p! f% @最后 systemctl start iptables 打开iptables
/ _1 n' O* t/ P" _9 |+ H Z. T
再执行service iptables save 9 T. C) W( v9 t- [. A+ I. m. {& E
然后重启iptables服务:
* h* Q& x- y0 R9 _4 X
service iptables restart ; B# d& x! r" d
执行完毕之后/etc/syscofig/iptables文件就有了
# X0 f5 ^+ B9 t8 J! T* S+ u |