Home Linux配置防火墙
Post
Cancel

Linux配置防火墙

CentOS6用service iptables status查看,CentOS7系统iptables叫firewalld,使用systemctl status firewalld查看。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 查看防火墙状态
systemctl status firewalld

# 如果不是显示active状态,需要打开防火墙
systemctl start firewalld

# 查看所有已开放的临时端口(默认为空)
firewall-cmd --list-ports

# 查看所有永久开放的端口(默认为空)
firewall-cmd --list-ports --permanent

# 添加临时开放端口
firewall-cmd --add-port=223/tcp

# 添加永久开放的端口
firewall-cmd --add-port=223/tcp --permanent

# 关闭临时端口
firewall-cmd --remove-port=80/tcp

# 关闭永久端口
firewll-cmd --remove-port=80/tcp --permanent

# 配置结束后需要输入重载命令并重启防火墙以生效配置
firewall-cmd --reload
systemctl restart firewalld
This post is licensed under CC BY 4.0 by the author.