Firewalld Gateway Policy Isn’t Forwarding Ports to My VM

0
1
Asked By MellowPine47 On

I'm setting up an AlmaLinux machine as a router using firewalld's gateway policy configuration. The basic filtering works as expected: incoming traffic is denied by default while permitted traffic is allowed. However, forwarding TCP ports 80 and 443 to a virtual machine at 10.42.0.2 does not work. I added these permanent policy rules and reloaded firewalld:

firewall-cmd --permanent --policy gateway-world-to-HOST --add-forward-port port=80:proto=tcp:toport=80:toaddr=10.42.0.2
firewall-cmd --permanent --policy gateway-world-to-HOST --add-forward-port port=443:proto=tcp:toport=443:toaddr=10.42.0.2
firewall-cmd --reload

The services running in containers on the VM are still unreachable from the WAN. It seems like traffic reaches the router but is not being forwarded onward to the VM. What configuration should I check?

5 Answers

Answered By SilverCedar19 On

You can also implement the forwarding directly with nftables if firewalld’s policy abstraction is getting in the way. That gives you explicit control over the destination NAT, forwarding accept rules, interface paths, and masquerading, but it still requires IP forwarding and correct routing on the VM.

Answered By VioletMesa31 On

Port forwarding needs more than the destination rewrite: the forwarded traffic must be allowed by the relevant policy, and return traffic needs a working route back through the router. Confirm that 10.42.0.2 uses the AlmaLinux router as its default gateway and that the VM’s own firewall allows ports 80 and 443. Packet captures on the WAN and VM interfaces can show where the traffic stops.

Answered By QuietHarbor8 On

First check whether IPv4 forwarding is enabled on the router. The kernel setting should be enabled with net.ipv4.ip_forward=1, both at runtime and persistently through sysctl configuration. Also verify the complete topology, including the WAN interface, the VM network, and the VM’s default gateway.

Answered By CopperLynx62 On

Make sure the policy you modified is actually the active policy for traffic arriving on the WAN interface. Check the active and default zones, interface assignments, and the policy’s ingress and egress zones. It’s easy to add a rule to a policy that is not handling the packets you’re testing.

Answered By AmberQuill74 On

Because the destination is a VM running containerized services, check the bridge and container networking as well as SELinux. The VM must be reachable from the router, and the services need to be listening on the VM’s address rather than only on a container-local interface. A container-focused firewalld configuration may be easier to troubleshoot than combining several independent rules.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.