Configure ufw for a web server with SSH only from the office.
BeginnerProductionFirewalls, MAC & Compliance
Answer
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 203.0.113.0/24 to any port 22 proto tcp
sudo ufw allow 80,443/tcp
sudo ufw enable
sudo ufw status numbered
Add the SSH rule before enable, or you lock yourself out of a remote box.
More on Firewalls, MAC & Compliance
How do ufw, firewalld, nftables and iptables relate?BeginnerExplain firewalld zones and runtime vs permanent configuration.IntermediateWrite a minimal nftables ruleset for a server.AdvancedWhy are nftables preferred over iptables at scale?AdvancedHow do you avoid locking yourself out when changing remote firewall rules?IntermediateHost firewall vs cloud security groups: do you need both?Intermediate