首先任意运行一条iptables防火墙规则配置命令如开通80端口:
) D+ Y" ~, g& z. v$ r( O/ r
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
: `* [+ R' b; F( z
然后对iptables服务进行保存:
5 A2 r7 @0 b5 f
service iptables save
. X. M7 M2 C! w: Y% v
如果失败报出: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. & Y. o7 C2 V- n( Y* N/ Z+ x* w- C
解决方法:# ]* i9 M& m, a+ h
systemctl stop firewalld 关闭防火墙
; g2 I$ P; l8 L. n0 Xyum install iptables-services 安装或更新服务
5 D/ t$ b7 X8 t6 ~# O再使用systemctl enable iptables 启动iptables
7 P0 l% ]+ S; a& W% y) i* O' j
最后 systemctl start iptables 打开iptables P* R) U* x$ K( b, c6 H
再执行service iptables save
- j9 v l3 W6 f; y
然后重启iptables服务: 7 ~7 [9 F8 F+ C! A9 O! k
service iptables restart
! P6 T/ q* u' B/ P9 Y+ F. `# }1 K
执行完毕之后/etc/syscofig/iptables文件就有了
0 R; t' ?; T; A$ n! Q |