防火墙:控制本机进出数据的服务
# 开启防火墙
[root@localhost network-scripts]# systemctl start firewalld.service
# 查看防火墙状态
# Active: inactive (dead) 关闭
# Active: active (running) 开启
[root@localhost network-scripts]# systemctl status firewalld.service
# 关闭防火墙
[root@localhost network-scripts]# systemctl stop firewalld
# 查看本机开启的服务
[root@localhost network-scripts]# netstat -lntup
# 查看防护墙开启的端口 默认开放22端口,以服务的形式开启的,该指令不显示
[root@localhost network-scripts]# firewall-cmd --list-ports
# 查看防火墙开启的服务
[root@localhost network-scripts]# firewall-cmd --list-services
# 开放指定端口
[root@localhost network-scripts]# firewall-cmd --add-port=80/tcp --permanent # 开放80端口 --permanent表示永久开启,如果想临时开启就不要加这个参数。
# 关闭端口
[root@localhost services]# firewall-cmd --zone=public --remove-port=80/tcp
# 开启指定服务
[root@localhost network-scripts]# firewall-cmd --zone=public --add-service=htttp # 添加http服务
# 关闭服务
[root@localhost network-scripts]# firewall-cmd --zone=public --remove-service=http # 关闭http服务
# firewall所有服务的定义的位置
/usr/lib/firewalld/services/