aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/network/firewall-cmd.md
blob: 03c268a3efd8dad03d00385ec03f226d57d92669 (plain) (blame)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# firewall-cmd(1)

Command line interface to the [firewalld(1)][man-firewalld] daemon.

## List current status of the firewall
```sh
# List all services and ports for all zones.
firewall-cmd --list-all
# List all services.
firewall-cmd --list-services
# List all ports.
firewall-cmd --list-ports
```
> Add `--zone <ZONE>` to limit output to a given `ZONE`. Use `--get-zones` to
> see all available zones.

## Add entries
```sh
# Add a service to the firewall, use `--get-services` to list all available
# service names.
firewall-cmd --add-service <SERVICE>
# Add a specific port.
firewall-cmd --add-port 8000/tcp
# Add a rich rule (eg port forwarding, dnat).
firewall-cmd --add-rich-rule 'rule family="ipv4" forward-port port="80" protocol="tcp" to-port="8080"'
```

## Remove entries
```sh
# Remove service.
firewall-cmd --remove-service <SERVICE>
# Remove port.
firewall-cmd --remove-port 8000/tcp
# Remove rich rule.
firewall-cmd --remove-rich-rule 'rule family="ipv4" forward-port port="80" protocol="tcp" to-port="8080"'
```

## References
- man [firewall-cmd(1)][man-firewall-cmd]
- man [firewalld(1)][man-firewalld]

[man-firewalld]: https://firewalld.org/documentation/man-pages/firewalld.html
[man-firewall-cmd]: https://firewalld.org/documentation/man-pages/firewall-cmd.html