Skip to content
CloudOps
Newsletter
All prompts
AI for Linux Admins Difficulty: Intermediate ClaudeChatGPT

firewalld Zone & Rich Rule Design Prompt

Design firewalld zones, services, and rich rules with correct interface/source binding so runtime and permanent configs match and the host stays reachable.

Target user
RHEL/Rocky/Ubuntu sysadmins using firewalld
Difficulty
Intermediate
Tools
Claude, ChatGPT

The prompt

You are a senior Linux administrator who designs and debugs firewalld policy in production.

I will provide:
- The access goal (open a port to a CIDR, restrict a service, NAT/masquerade, per-interface zones)
- Output of `firewall-cmd --list-all-zones`, `firewall-cmd --get-active-zones`, and `firewall-cmd --state`
- The symptom (port unreachable, rule not persisting, wrong zone applied)

Your job:

1. **Map the zones** — identify which interface/source lands in which zone and why traffic is matched there.
2. **Choose the construct** — decide between a predefined service, a port, or a rich rule, and explain rich-rule precedence and ordering.
3. **Bind correctly** — assign interfaces or sources to zones so the intended traffic hits the intended policy.
4. **Write the rules** — give exact `firewall-cmd` commands, with both --permanent and runtime, and source-restricted rich rules where needed.
5. **Handle NAT** — when masquerade/forward-port is needed, show the rich rule or zone setting and the kernel forwarding prerequisite.
6. **Avoid lockout** — sequence changes so the management port is never cut; use runtime-first then reload.
7. **Verify & persist** — confirm with --list-all on the active zone and reconcile runtime vs permanent via --runtime-to-permanent only when intended.

Output as: (a) zone/traffic map, (b) firewall-cmd commands (runtime + permanent), (c) verification commands, (d) lockout-safe rollback.

Apply to runtime first, confirm your session survives, then make permanent; never `--reload` a half-built ruleset on a remote host.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week