Windows netsh advfirewall (firewall rules) equivalent in Linux
Controls which network traffic is allowed through the system's firewall.
netsh advfirewall (firewall rules)
sudo ufw allow 22/tcp
sudo firewall-cmd --add-service=ssh --permanent && sudo firewall-cmd --reload
sudo ufw allow 22/tcp
Overview
What this command does
On Windows, "netsh advfirewall (firewall rules)" is used to manage firewall rules. On Linux, the closest practical mapping shown here is "ufw". Controls which network traffic is allowed through the system's firewall. This reference is grouped under Security & Permissions → Networking.
Windows → Linux context
What changes when you use this on Linux?
Equivalent task, different tool
Windows netsh advfirewall (firewall rules) maps to ufw for this task. Treat this as a workflow mapping rather than a character-for-character syntax translation.
Distribution details matter
The Debian/Ubuntu, Fedora and Arch rows are not identical. Use the row for your distribution instead of changing only the package-manager name in an example.
Elevated privilege appears in this workflow
At least one example uses sudo. Confirm the target path, device, service or package before running the elevated form; do not add sudo simply to bypass an unexplained permission error.
Command-specific caution
Always allow SSH (port 22) before enabling the firewall on a remote server, or you will lock yourself out.
For the broader concept behind this mapping, read Linux permissions for Windows users.
Practical tasks
Common use cases
Manage firewall rules
Controls which network traffic is allowed through the system's firewall.
ufw status
Show firewall status and rules
ufw enable / disable
Turn firewall on or off
ufw allow 22
Allow SSH (port 22)
Ready to run
Copyable Linux commands
Review paths, device names, package names and permissions before running any command.
sudo ufw status
sudo ufw enable
sudo ufw allow ssh
sudo ufw allow 80,443/tcp
sudo ufw status numbered
Walkthrough
Examples with explanations
# Windows: netsh advfirewall firewall add rule ...
sudo ufw status # view rules
sudo ufw enable # turn on
sudo ufw allow ssh # allow SSH
sudo ufw allow 80,443/tcp # allow web traffic
sudo ufw status numbered # numbered list of rules
Reference
Common options and variations
| Command or option | Use |
|---|---|
ufw status | Show firewall status and rules |
ufw enable / disable | Turn firewall on or off |
ufw allow 22 | Allow SSH (port 22) |
ufw allow 80/tcp | Allow HTTP traffic |
ufw deny from 192.168.1.50 | Block a specific IP |
ufw delete allow 80 | Remove a rule |
Distro differences
Debian/Ubuntu vs Fedora vs Arch
The equivalent is distribution-specific for this task: Debian/Ubuntu uses "sudo ufw allow 22/tcp"; Fedora uses "sudo firewall-cmd --add-service=ssh --permanent && sudo firewall-cmd --reload"; Arch uses "sudo ufw allow 22/tcp".
| Distribution | Package manager / base | Equivalent command | Difference to notice |
|---|---|---|---|
| Debian/Ubuntu | apt / ufw | sudo ufw allow 22/tcp |
Ubuntu commonly uses ufw as a simple firewall frontend. |
| Fedora | dnf / firewalld | sudo firewall-cmd --add-service=ssh --permanent && sudo firewall-cmd --reload |
Fedora commonly uses firewalld instead of ufw. |
| Arch | pacman / ufw or nftables | sudo ufw allow 22/tcp |
Arch does not force one firewall frontend; install and enable ufw, firewalld or nftables. |
Important
What to watch out for
Keep learning