|
首先任意运行一条iptables防火墙规则配置命令如开通80端口: ' S9 n7 w' [" r9 `; a
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT : U5 K, t2 l4 s) b# f3 j
然后对iptables服务进行保存: 8 p! w9 I; W( @( F
service iptables save
8 D2 d0 v" V4 D, T5 c* e5 k1 d
如果失败报出: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.
g! w7 e6 R" e( [& t/ o
解决方法:
1 H9 w( s- R" n8 \systemctl stop firewalld 关闭防火墙 : {2 M7 @ B9 q0 [7 H
yum install iptables-services 安装或更新服务 $ y8 F4 i1 B* P
再使用systemctl enable iptables 启动iptables / ]' f7 T; l9 e0 v Z R J* A
最后 systemctl start iptables 打开iptables 8 Y) S& w4 {: |) J* S1 F
再执行service iptables save
* u& w5 K: i2 J7 x
然后重启iptables服务:
# s9 E$ x8 z/ _
service iptables restart ) f) F5 B0 {7 N: k6 V
执行完毕之后/etc/syscofig/iptables文件就有了
/ A8 y. |! h+ p$ b Q |