I was going through the mikrotik default firewall rules trying to make sure I had a fundamental understanding of all of them, as well as trying to figure out how they map to iptables rules. I got to the forward WAN drop rule, and realized there was one part I didn’t understand. This is the rule I’m referring to:
/ip firewall filter add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="defconf: drop all from WAN not DSTNATed"
My understanding is that this rule is meant to prevent any external/incoming FORWARD requests from initiating NEW connections; the intended flow should be an internal/outgoing FORWARD request sets the connection-state to NEW, and then the external/incoming FORWARD responses should set the connection-state to ESTABLISHED in PREROUTING. Couldn’t that be accomplished with just this?
/ip firewall filter add chain=forward action=drop connection-state=new in-interface-list=WAN comment="defconf: drop all from WAN not DSTNATed"
Isn’t the
connection-nat-state=!dstnat
redundant here (based on my understanding of what the rule is trying to accomplish)?
My understanding is that for a packet to be put in the FORWARD chain in the first place (instead of the INPUT chain), the packet’s src-ip, src-port, dst-ip (the routers public ip) and dst-port all needed match an existing connection in the connection-list and point to the client that made the request, and if no connection was matched, it would be sent to the INPUT chain instead. Therefore if the packet was placed on the forward chain, wouldn’t that mean a connection in the connection-list was found and dstnat was applied, making the connection-nat-state=!dstnat part of the rule redundant?
I think I have a fundamental misunderstanding of when connection-nat-state=dstnat gets applied. This also seems to make the rule less secure, because it narrows down the DROP scope, and mikrotik has a default ALLOW policy after this. There also seems to be very little information about exactly what scenarios connection-nat-state gets applied: the places I cant find these topics mentioned are, dstnat, connection-nat-forwarding and general NAT.
I was hoping someone might help me understand what
connection-nat-state=!dstnat
is trying to accomplish in the default rule, as well as when the
connection-nat-state
gets updated (I have already read through the RouterOS packet flow page but that didn’t really clear up my confusion).