怎么设置centos防火墙
时间: 2024-01-28 16:12:10 浏览: 72
以下是设置CentOS防火墙的步骤:
1. 查看防火墙状态
```shell
systemctl status firewalld
```
2. 启动防火墙
```shell
systemctl start firewalld
```
3. 停止防火墙
```shell
systemctl stop firewalld
```
4. 重启防火墙
```shell
systemctl restart firewalld
```
5. 开机启动防火墙
```shell
systemctl enable firewalld
```
6. 关闭开机启动防火墙
```shell
systemctl disable firewalld
```
7. 查看防火墙状态
```shell
firewall-cmd --state
```
8. 查看防火墙规则
```shell
firewall-cmd --list-all
```
9. 开放端口
```shell
firewall-cmd --zone=public --add-port=80/tcp --permanent
```
10. 开放服务
```shell
firewall-cmd --zone=public --add-service=http --permanent
```
11. 移除端口
```shell
firewall-cmd --zone=public --remove-port=80/tcp --permanent
```
12. 移除服务
```shell
firewall-cmd --zone=public --remove-service=http --permanent
```
13. 重新载入防火墙规则
```shell
firewall-cmd --reload
```
14. 添加FTP服务
```shell
firewall-cmd --zone=public --add-service=ftp --permanent
```
15. 添加端口范围
```shell
firewall-cmd --zone=public --add-port=5000-5500/tcp --permanent
```
阅读全文