|
首先任意运行一条iptables防火墙规则配置命令如开通80端口: ) ]9 e: z: R3 @3 m1 t* i; O* t
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT * |8 D# O) P1 k
然后对iptables服务进行保存: 9 X4 r& ~7 ]0 [7 j
service iptables save
' e! p# m6 p! v5 A: M; m
如果失败报出: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.
4 l" J$ b- f$ g) D3 p1 C9 T ~1 z
解决方法:
( V: W0 ?7 K ]# Q; i8 t* Q8 Y* w$ ksystemctl stop firewalld 关闭防火墙
5 D& S8 }! q3 Q- [( B3 a; | uyum install iptables-services 安装或更新服务
0 {3 z9 t/ R% ?6 y' A2 P再使用systemctl enable iptables 启动iptables
' z- M$ c' p# x( {最后 systemctl start iptables 打开iptables
- j5 k; p; r# ?: Q3 U3 u: x5 R, a% e8 B
再执行service iptables save
. ^ V! \6 j+ u: @( s/ ~5 A j
然后重启iptables服务: 4 R+ @1 Q8 b. [
service iptables restart
1 C: {, Q% o) ?: Z
执行完毕之后/etc/syscofig/iptables文件就有了 ( D7 w, s _7 d
|