iptables 相关操作
1 # 查看防火墙状态
2
3 service iptables status
4
5 # 停止防火墙
6
7 service iptables stop
8
9 # 启动防火墙
10
11 service iptables start
12
13 # 重启防火墙
14
15 service iptables restart
16
17 # 永久关闭防火墙
18
19 chkconfig iptables off
20
21 # 永久关闭后重启
22
23
firewalld相关操作
//屏蔽
systemctl mask firewalld
//取消
systemctl unmask firewalld
//启动
systemctl start firewalld
//状态
systemctl status firewalld
//停止
systemctl stop firewalld
//禁用
systemctl disable firewalld
//开机启用
systemctl enable firewalld.service
//开机禁用
systemctl disable firewalld.service
//查看开机启用
systemctl is-enabled firewalld.service
//查看已启动的服务
systemctl list-unit-files|grep enabled
//查看启动失败的服务
systemctl --failed
//查询特定端口是否开放
firewall-cmd --query-port=80/tcp
//开放特定端口
firewall-cmd --permanent --add-port=80/tcp
//关闭特定端口
firewall-cmd --permanent --remove-port=8080/tcp
//查看已开放的端口
firewall-cmd --list-ports
//重启防火墙
无iptables文件解决:
在RHEL 7 / CentOS 7中,firewalld被引入来管理iptables,CentOS7开始,默认是没有iptables的,而是使用firewall防火墙。本文将屏蔽掉firewall,使用iptables
Centos7版本解决方法:
1、停止并屏蔽firewalld服务:
停止:
systemctl stop firewalld
屏蔽:
systemctl mask firewalld
2、安装iptables-service软件包:
yum install iptables-services
3、在引导时启用iptables服务:
systemctl enable iptables
4、启动iptables服务:
systemctl start iptables
5、保存防火墙规则:
service iptables save