|
首先任意运行一条iptables防火墙规则配置命令如开通80端口:
8 u& X3 Z, m. ^3 _
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
) k! R6 B2 O, r. D! m+ h
然后对iptables服务进行保存:
- y2 {. S9 @5 b3 S( g# Q; V7 v4 m
service iptables save
0 w1 B" Z9 x. {
如果失败报出: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. 6 {: `9 P7 V; l1 h% r
解决方法:: v6 a! Y: f' H1 _/ r' U: H
systemctl stop firewalld 关闭防火墙
- J" b4 V/ C& n* v+ j6 ^3 A* Kyum install iptables-services 安装或更新服务
2 T, `4 \0 Q) D I再使用systemctl enable iptables 启动iptables
% e* j9 O( @1 h* |5 b0 `; P) E
最后 systemctl start iptables 打开iptables
9 h T2 F! O1 ]+ o
再执行service iptables save
# e8 n' F4 M- ?
然后重启iptables服务:
2 r5 c4 v: M. \: V% t$ b
service iptables restart
- o* X' N. t" `% B! R; E
执行完毕之后/etc/syscofig/iptables文件就有了 ; ?$ {( s. B+ Z1 _6 I
|