It’s about month as I’m trying to resolve one strange issue with firewall on Fedora 38.
For simplifying it and to avoid additional questions about my personal configuration I will describe it on booting Live Fedora 38 Workstation image from USB.
Here is steps to easily reproduce that what I’m talking about.
Boot Fedora 38 Live image.
Install additionally nmap (it will be needs later to experiment).
Configure firewall to forwarding all incoming TCP traffic from port 80 to local port 8080
Start simple mock to response on port 8080 sudo nc -lp 8080 <<< hello
Try to access to port 80 on this computer (it doesn’t matter to use locahost or real IP address) curl localhost
What I expected here is to get response - hello, but instead of this curl: (7) Failed to connect to localhost port 80 after 0 ms: Couldn’t connect to server
But the most fanny thing here is that it work fine when you execute curl with IP of this computer, from the device in the same network with your computer.
I would really appreciate for any explanations why it shouldn’t work, because I think that there are no reasons for such behavior.
As I already seen it the rich rules is more preferable way to organize port forwarding. And of course I already tried it. This is one what I started with.
That seems logical. One is forwarding an incoming connection to a different port on the localhost address.
@mykola
What happens if you try to connect from the local host to port 80 on the LAN ip of the local host.? It should be seen and treated the same as a connection from another host on the lan.
This is pretty old https://bugzilla.redhat.com/show_bug.cgi?id=1445918#c6
it is not strictly related to Fedora Linux, and it is using iptables and not nft who is used on Fedora Linux nowadays.
But maybe: firewalld implements forward-ports using the iptables nat PREROUTING chain. This chain is not used for packets sent over the loopback interface as packets over the loopback should not be routed.