Declarative firewalld configuration generator. Write YAML, get firewall-cmd scripts.
Bug tracker: GitHub Issues | Discord: Join
Funding: Buy Me a Coffee | GitHub Sponsors | Patreon
Firegen takes a YAML configuration describing firewalld zones, ports, services, rich rules, and direct rules, then generates ready-to-run firewall-cmd apply and remove scripts. It supports variables, loops, and rule_groups to keep configurations DRY across IPv4/IPv6.
Runs entirely in the browser. No backend, no telemetry, no dependencies at runtime.
git clone https://github.com/studiowebux/firegen.git
cd firewalld
python3 -m http.server 8090Open http://localhost:8090.
docker compose up -dOpen http://localhost:8090.
Copy the repo contents to any static file server (nginx, Caddy, S3, GitHub Pages). No build step required.
Write YAML in the left panel. Generated firewall-cmd commands appear in the right panel under Apply and Remove tabs.
variables:
web_ports:
- 80
- 443
zones:
public:
target: DROP
interfaces:
- eth0
services:
- ssh
ports:
- port: "{{ item }}"
protocol: tcp
loop: "{{ web_ports }}"Define reusable values under variables:. Reference them with {{ variable_name }}. List variables expand in loop: directives.
Add loop: "{{ list_variable }}" to any array item. The item is duplicated for each value, with {{ item }} replaced by the current value.
Use rule_groups under direct: to share rules across IP versions:
direct:
rule_groups:
- ipv: [ipv4, ipv6]
table: filter
chain: DOCKER-USER
rules:
- priority: 1
args: "-m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT"
- priority: 10
args: "-j DROP"The built-in {{ ipv_any }} variable resolves to 0.0.0.0/0 for ipv4 and ::/0 for ipv6.
Use the Import and Export buttons to load and save YAML configuration files.
- Open the app and review the preloaded example
- Modify the YAML or import your own configuration
- Copy the Apply script and run it on your server
- Keep the Remove script to roll back changes
See examples/docker-firewall.yaml for a production configuration protecting Docker containers behind firewalld.
Contributions are welcome. Open an issue first to discuss changes.
Apache-2.0. See LICENSE.