> ## Content Index
> Fetch the complete content index at: https://note.xdq.me/llms.txt
> Use this file to discover other available public pages before exploring further.

# centos 7 firewalld常用命令
- URL: https://note.xdq.me/centos-7-firewalldchang-yong-ming-ling/
- Published: 2014-11-07T00:33:09.000Z
- Updated: 2026-10-03T03:09:10.000Z
- Author: xud6
- Tags: centos, linux, #Import 2026-10-03 02:45

将ip添加到zone

```
sudo firewall-cmd --permanent --zone=work --add-source=192.168.0.0/24

```

将某个网口添加到zone

```
sudo firewall-cmd --permanent --zone=work --add-interface=eth0

```

在某个zone打开端口

```
sudo firewall-cmd --permanent --zone=work --add-port=8080-8090/tcp

```

永久打开一个端口

```
firewall-cmd --permanent --add-port=8080/tcp

```

永久关闭一个端口

```
firewall-cmd --permanent --remove-port=8080/tcp

```

永久打开某项服务

```
firewall-cmd --permanent --add-service=http

```

永久关闭某项服务

```
firewall-cmd --permanent --remove-service=http

```

进行端口转发

```
firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=8080:toaddr=192.0.2.55

```

允许转发到其他地址

```
firewall-cmd --permanent --add-masquerade

```

重新加载防火墙

```
firewall-cmd --reload

```