Originally Posted by
georgschmidt
Yes, that works. But why? I thought that with "-A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT" I allow incoming traffic if it is a response to an outgoing one. Since I don't specify an interface, isn't that rule also valid for the lo interface. So the local host can send the response back.
Or is it, because the local host is basically my machine as well, it doesn't receive the first request, because it is blocked by the INPUT rule. Is my understanding correct that if I send sth to local host, I basically send it to myself and it goes through the OUTPUT (because it comes from my machine) and INPUT channel (because my machine also receives it). So for anything to LO, both INPUT AND OUTPUT policy / rules are valid?
Thank you very much
I think the issue is really that the rules apply to the packets without knowledge of the overall topology. It doesn't make the association between the outgoing request and the incoming request.
There's an outgoing request sent to lo e.g. (127.0.0.1:50001 -> 127.0.0.53:53).
The matching response (ESTABLISHED,RELATED) would be (127.0.0.53:53 -> 127.0.0.1:50001) so a rule for that is entered into the connection tracking table for that.
Then an incoming request arrives on lo (127.0.0.1:50001 -> 127.0.0.53:53). That's not the expected response, that's a brand new incoming request, from a different IP and port number. And there's no rule for allowing such incoming requests, so it gets dropped.
Here's an interesting test: Open 3 terminal sessions. On the first, open a listening port with the command:
Code:
netcat -lv -s 127.42.123.66 -p 9999
Leave that listening and on the second terminal, connect to it (you can type messages between the two):
Code:
netcat -v 127.42.123.66 9999
On the third terminal, look at current tcp connections:You will see two entries for port 9999, one for each end. They have different remote addresses. In this case you're looking in a mirror and talking to yourself (because network 127), but the firewall rules don't know that.