Linux & shell: Firewall (ufw, firewalld, iptables, nftables)
7 Linux & shell commands: Firewall (ufw, firewalld, iptables, nftables). Click a command to see what each part does.
Linux & shell: Firewall (ufw, firewalld, iptables, nftables)Index
- Whole sheet251
- Navigate & list13
- Create, copy, move, delete13
- View & compare files9
- Permissions & ownership31
- Help & shell basics11
- Users & groups6
- Install packages7
- Package & software versions29
- System info9
- Network basics & SSH10
- Zip & compress4
- Shell operators6
- Processes6
- Files & search8
- Text processing pipelines4
- Disk3
- Network5
- Services & logs6
- Archives & copying4
- Firewall7
- Scheduling: cron & systemd timers6
- Storage, mounts & LVM10
- Kernel, hardware & limits8
- Performance & tracing10
- TLS & certificates8
- Packet capture & network debugging10
- Terminal tools8
Firewall (ufw, firewalld, iptables, nftables)7
sudo ufw status verboseFirewall status and rules (Ubuntu ufw)What each part does
ufw statusactive or not, and each allow/deny ruleverbosealso default policies and logging level
sudo ufw allow <port>/tcpAllow a port (ufw)CautionWhat each part does
ufw allowadd an allow rule (ufw allow from <ip> to any port <port> to restrict the source)<port>/tcpport and protocol
sudo firewall-cmd --list-allFirewall rules (RHEL firewalld)What each part does
firewall-cmd --list-allthe default zone's services, ports, rich rules and interfaces
sudo firewall-cmd --permanent --add-port=<port>/tcp && sudo firewall-cmd --reloadOpen a port permanently (firewalld)CautionWhat each part does
--permanentsave to config (without it the rule is lost on reload)--add-port=<port>/tcpopen the port in the default zone (or --add-service=https)--reloadapply the saved config
sudo iptables -L -n -v --line-numbersList iptables rules with countersWhat each part does
-Llist rules of the filter table-nnumeric, no DNS lookups-vpacket/byte counters and interfaces--line-numbersrule numbers, for deleting by number
sudo iptables -t nat -L -n -vList NAT rules (port forwards, Docker, Kubernetes)What each part does
-t natthe NAT table: DNAT port forwards and MASQUERADE rules
sudo nft list rulesetShow the full nftables rulesetWhat each part does
nft list rulesetevery table, chain and rule (newer distros use nftables under firewalld and iptables-nft)
Nothing matches.
My DevOps Playbook by Angelo John Calleja