Dev.to Security 🔐 Cybersecurity 👁 0 📖 4 min read

firewalld for Servers in a Free /48: Zones, Sources and Rich Rules

Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end. firew

Disclosure up front: I run IPYE, a company that leases IP space. Most of this article is practical how-to; IPYE appears where a free /48, LOA, or ROA helps you try the work, with a short call to action at the end.

firewalld is the default firewall manager on RHEL, Fedora, Rocky, AlmaLinux and openSUSE. It thinks in zones rather than raw rules, which suits servers well once you know how traffic is matched to a zone. With globally routable IPv6 addresses from your own prefix, every server is directly reachable, so getting zones right matters more than it did behind NAT. This guide configures firewalld on servers numbered from a free IPv6 /48 from IPYE, with 2001:db8:100:5::/64 as the management network and the server at 2001:db8:100:10::20.

How firewalld picks a zone

Each packet is matched to exactly one zone:

  1. if its source address matches a source bound to a zone, that zone is used
  2. otherwise, the zone of the incoming interface is used
  3. otherwise, the default zone

Source bindings are what make firewalld pleasant for IPv6. Bind your management /64 to a zone with more access, and every other source falls through to the interface's stricter zone.

firewall-cmd --get-active-zones
firewall-cmd --get-default-zone

A management zone by source

firewall-cmd --permanent --new-zone=mgmt
firewall-cmd --permanent --zone=mgmt --add-source=2001:db8:100:5::/64
firewall-cmd --permanent --zone=mgmt --add-service=ssh
firewall-cmd --permanent --zone=mgmt --add-service=cockpit
firewall-cmd --reload

Now SSH and Cockpit are open only to the management network. An alternative to a new zone is the built-in internal or trusted zone. trusted accepts everything from the bound sources, which is too broad for most management networks; a dedicated zone with named services is easier to reason about.

Remove SSH from the public zone once you have confirmed that you can log in from a management host:

firewall-cmd --permanent --zone=public --remove-service=ssh
firewall-cmd --reload

Do this from a session that originates in the management /64, or keep a console open. Removing SSH from the zone your current session uses is the most common way to lock yourself out.

Public services

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
firewall-cmd --zone=public --list-all

Services apply to both address families, so these lines open ports 80 and 443 on IPv4 and IPv6 alike.

Address-specific rules

A server with several addresses might run a public web service on one and an internal API on another. Rich rules match on the destination address:

firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv6" destination address="2001:db8:100:10::21" port port="8443" protocol="tcp" accept'

Port 8443 is now open only on 2001:db8:100:10::21, not on the server's other addresses. Rich rules also handle the reverse case, blocking one address range:

firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv6" source address="2001:db8:dead::/48" drop'

Prefer source-bound zones for allow lists and rich rules for exceptions, so the configuration stays readable.

ICMPv6

firewalld permits the ICMPv6 types needed for neighbour discovery and path MTU discovery by default. Check that nothing important is blocked:

firewall-cmd --zone=public --list-icmp-blocks

An empty result is what you want. Blocking packet-too-big in particular causes stalls on large transfers that look like application bugs.

Logging denied traffic

firewall-cmd --set-log-denied=unicast
journalctl -k -g "REJECT|DROP" --since "10 minutes ago"

Logging denied unicast packets helps while you tune the rules. Turn it off again on busy public servers, since scans of your addresses can produce a lot of log lines. On IPv6 such scans are less common than on IPv4 because the address space is too large to sweep, but addresses published in DNS or seen in certificate logs are found quickly.

Permanent versus runtime

Every command without --permanent changes only the running configuration and is lost on reload or reboot. A useful pattern is to test with runtime changes first, confirm that everything works, then run firewall-cmd --runtime-to-permanent to save the result. That gives you a safe trial period without editing XML files by hand.

Configuration management

firewalld stores permanent configuration as XML under /etc/firewalld/. Keep those files in configuration management, or drive firewalld through your tool's firewalld module, so that every server in the /48 gets the same zones and source bindings.

Behind the firewall: the route

The host firewall decides what reaches the service; the route decides whether traffic reaches the host at all. For the /48, that means an announcement backed by the LOA from the IPYE portal and the ROA IPYE creates.

Next step

Claim your free /48, reserve a /64 for management, and bind it to its own firewalld zone before you open anything to the public. Questions: [email protected].

About IPYE

IPYE (https://ipye.com) leases IPv4, IPv6 and ASN space with instant setup. Your first IPv6 /48 is free for the first year, a real allocation you can announce on your own ASN, with a LOA from the portal and the ROA created automatically. ASN and region changes apply automatically. IPv4 /24 to /22 leases include LOA, ROA and per-/24 rDNS; WHOIS is editable on IPv6 /44 and larger. Locations: Los Angeles, New York, Ashburn, Salt Lake City, London, Amsterdam, Frankfurt. Claim your free /48: https://my.ipye.com/products/ipv6-rental. Questions: [email protected].

Disclosure: I run IPYE

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.