Windows
Linux
Security & Permissions
Networking
Windows netsh advfirewall (firewall rules) equivalent in Linux
Controls which network traffic is allowed through the system's firewall.
Windows
→
netsh advfirewall (firewall rules)
Linux equivalents
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
Controls which network traffic is allowed through the system's firewall.
Migration tip:
ufw (Uncomplicated Firewall) is the easy-to-use front-end for Linux firewalls on Ubuntu/Debian. firewalld is used on Fedora/RHEL. Both sit on top of iptables/nftables.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
This command can differ by distro defaults or package manager.
| 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
Always allow SSH (port 22) before enabling the firewall on a remote server, or you will lock yourself out.
Keep learning