An RPM package that uses firewalld ipset + rich rules to allow HTTP/HTTPS (80/443) only from Cloudflare IPs.
# Build and install the RPM
make rpm
sudo dnf install ~/rpmbuild/RPMS/noarch/firewalld-cloudflare-http-*.rpmThe following steps are performed automatically during installation:
- Fetches Cloudflare's public IP lists (IPv4, IPv6)
- Creates firewalld ipsets (
cloudflare-ipv4,cloudflare-ipv6) - Adds rich rules to the default zone to allow HTTP/HTTPS
- Sets up a weekly systemd timer to automatically update the IP lists
# Check ipsets
sudo firewall-cmd --get-ipsets
sudo firewall-cmd --info-ipset=cloudflare-ipv4
sudo firewall-cmd --info-ipset=cloudflare-ipv6
# Check rich rules
sudo firewall-cmd --list-rich-rules
# Check timer
systemctl status firewalld-cloudflare-http-update.timerTo deny HTTP/HTTPS from non-Cloudflare IPs, remove the http/https services from the zone:
sudo firewall-cmd --permanent --remove-service=http
sudo firewall-cmd --permanent --remove-service=https
sudo firewall-cmd --reload# Manually update the IP lists
sudo /usr/libexec/firewalld-cloudflare-http/update update
# Re-run setup (optionally specify a zone)
sudo /usr/libexec/firewalld-cloudflare-http/update setup [zone]sudo dnf remove firewalld-cloudflare-httpRich rules and ipsets are automatically removed during uninstallation.
rpmbuild(rpm-buildpackage)make
sudo dnf install rpm-build make
make rpmApache License 2.0