|
首先任意运行一条iptables防火墙规则配置命令如开通80端口:
& d6 a0 E) p- \% L" A: O
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT & Y2 N4 J1 y5 n) S
然后对iptables服务进行保存: # F( l$ K9 z6 j S
service iptables save
8 o& w5 D; c: X. j
如果失败报出: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.
. v0 F; k# F4 u' k0 ]% p" Q6 j
解决方法:
" C8 u; S3 o2 w/ I% {7 xsystemctl stop firewalld 关闭防火墙 ! \0 }( ~7 H- U" ]
yum install iptables-services 安装或更新服务 3 |, p' y1 Q7 K' w
再使用systemctl enable iptables 启动iptables 7 Y: W6 }! c+ J6 W9 |3 q- h
最后 systemctl start iptables 打开iptables 6 ~1 u- @0 ~5 a; V
再执行service iptables save
2 W% l4 I8 r: K5 D( j( R5 z4 B7 E
然后重启iptables服务: 8 C3 I1 V/ x8 O3 w* c) m! g
service iptables restart
7 \$ w" v7 H3 I& f
执行完毕之后/etc/syscofig/iptables文件就有了 ; z" b t+ R3 n, v' y; |
|