Prepare UFW for Cloudflare IP ranges
masterBefore installing the script, ensure UFW is configured correctly to prevent lockout.
- Check status: Run
sudo ufw status verbose. If it showsStatus: inactive, you can skip to the installation. If active, disable it withsudo ufw disable. - Reset rules: Run
sudo ufw resetto return to default settings. - Set default policies: Set the firewall to deny all incoming connections and allow all outgoing connections:
sudo ufw default deny incomingsudo ufw default allow outgoing
- Prevent lockout: Crucially, allow your local network and SSH before enabling the firewall:
- Allow local network (example:
sudo ufw allow from 192.168.1.0/24) - Allow SSH:
sudo ufw allow ssh
- Allow local network (example:
- Enable UFW: Run
sudo ufw enable. When prompted with a warning about disrupting SSH connections, typeYto continue.
sudo ufw status verbose
sudo ufw disable
sudo ufw reset
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.1.0/24
sudo ufw allow ssh
sudo ufw enable