ICMP: Input vs Forward chain

I have some questions about ICMP (IPv4 only) and the RouterOS configuration.

Blocking ICMP traffic could break core networking techniques (like Path MTU Discovery).

The default RouterOS configuration has a default firewall rule to allow ICMP traffic on the Input chain.
But there is no allow ICMP rule on the Forward chain.

  • Is ICMP traffic from LAN to WAN connections (like browsing the web) always seen as RELATED traffic? Is that the reason why there is no ICMP rule on the Forward chain?
  • If the above is true, is the ICMP rule on the input chain only for traffic originating from the internet to the router itself? Or other traffic as well? What are some examples of this kind of traffic, as I don't have any services (server, VPN, ...) exposed to WAN side of the router.

Just trying to improve my understanding of how things work.

Thank you!

IN means: trafic toward router's interfaces that ends it's life in a router.

FORWARD: traffic WAN -> LAN & LAN -> WAN, LAN <-> LAN that passes through the router - maybe it is processed somehow during that pass

OUT: traffic originated by router and leaving it.

No, it's not "related" traffic per se. Rather, it's "NAT'ed" just like TCP traffic would be from LAN.

It confusing since the defconf firewall defaults uses interface-list filters works later in the firewall that indirectly allow ICMP (and LAN origin traffic), since there is not simple drop at end, you don't have "allow" ICMP to WAN. Instead, RouterOS structures it as:

add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat connection-state=new in-interface-list=WAN

So WAN inbound is blocked on forward, but LAN outbound does NOT hit any filter,.. so it passes to /ip/firewall/nat, which srcnat the ICMP from LAN, and then it's add to connection tracking.

You can test yourself, by disabling fasttrack (if enabled) then add ICMP coming from WAN logging rules for both the input and forward chain at the top of the filter table. As example:

  • Green: When a client in LAN ping some remote address, NAT applies and the ICMP echo reply packets are tracked as established and are allowed through by the normal "accept established, related" rule of the forward chain.

  • Orange: When a client makes outgoing connection (non ICMP), NAT still applied, and some error condition needs to be reported back via ICMP, that ICMP packet is tracked as related, and is also affected by the "accept established, related" rule of the forward chain.

  • Purple: When the router itself tries to ping something, the response ICMP echo reply packets have the established connection state and are caught by the "accept established, related" rule of the input chain.

  • Blue: When the router make outgoing connections (non ICMP) and some error condition needs to be reported back via ICMP, the ICMP packet has connection state related, and is also caught by the "accept established, related" rule of the input chain.

Which means for IPv4, with the default defconf firewall rules, the "defconf: accept ICMP" rule (which sits below "defconf: accept established,related,untracked" of input) mostly only catches incoming ping requests (ICMP echo request) or bogus ICMP packets. And is not needed for handling errors of connections originated from LAN or from the router itself.

Hello everyone,
Based on the description above, is the following setup feasible—would it be correct, and would it actually work?
For the inbound chain, I would allow ICMP traffic only from an address list containing specific addresses I’ve defined. For outbound requests, I would create a similar rule, but apply a filter based on specific source addresses from the router's LAN side (using a source address list). Regarding the LAN side, should this rule be applied to the OUTPUT or INPUT chain? Has anyone experimented with an idea like this? I’m curious about the implementation. I have a test environment available, which is why I’m bringing this up. Does such a setup make sense?
Thanks

//-No.

I guess we're missing what the problem you're having? The default firewall is pretty well-designed for a common LAN/WAN split without modifications. If you add interfaces like VLANs, if those go to the LAN interface-list, firewall works same. It only when you want to block IPv4/IPv6 between local interfaces (*really, "subnets"), do you need to change the firewall.

@Amm0

Fair enough :slight_smile: But the idea crossed my mind to control who can ping from the WAN side and who cannot. Similarly, to manage this from the LAN side of the router as well. I’m referring to a standard router configuration—no VLANs, etc. It never hurts to experiment :slight_smile:

Thanks

Thank you all and thank you @CGGXANNX for the very clear example.

By default, the only thing pingable from the WAN is the router itself,nothing else.

???

If you want to dig into ICMP and firewall, I'd suggest looking some of @Kentzo's firewall examples, since he takes a very sophisticated approach to handling ICMP. e.g. using tcp-reset instead of dumb drop, among others.

Need to check if I made changes to ICMP handling since the post.

It does look sophisticated in the configuration but modern edge routers easily handle such load.

Cleaned by autor

Maybe you should open another topic instead of hijacking this one with your redhat skills.

We also like clean topics.

Here is how my current firewall handles ICMP and ICMPv6 as well as uses it to reject unwanted connections from LAN:

/ip/firewall/filter> export where chain=input      
add action=jump chain=input comment="Input: Jump to Invalid" connection-state=invalid jump-target=invalid
# .. a bunch of accepts
add action=accept chain=input comment="Input: Accept ICMP" protocol=icmp
add action=reject chain=input comment="Input: Reject All from LAN" in-interface-list=LAN reject-with=icmp-admin-prohibited
add action=drop chain=input comment="Input: Drop All"

/ip/firewall/filter> export where chain=forward
add action=jump chain=forward comment="Forward: Jump to Invalid" connection-state=invalid jump-target=invalid
# ... a bunch of accepts
add action=reject chain=forward comment="Forward: Reject All from LAN" in-interface-list=LAN reject-with=icmp-admin-prohibited
add action=drop chain=forward comment="Forward: Drop All"

/ip/firewall/filter> export where chain=invalid
add action=accept chain=invalid comment="Invalid: Accept Invalid FIN" protocol=tcp tcp-flags=fin
add action=accept chain=invalid comment="Invalid: Accept Invalid RST" protocol=tcp tcp-flags=rst
add action=accept chain=invalid comment="Invalid: Accept Invalid FIN,ACK" protocol=tcp tcp-flags=fin,ack
add action=reject chain=invalid comment="Invalid: Reject Invalid TCP from LAN" in-interface-list=LAN protocol=tcp reject-with=tcp-reset
add action=reject chain=invalid comment="Invalid: Reject Invalid from LAN" in-interface-list=LAN reject-with=icmp-admin-prohibited
add action=drop chain=invalid comment="Invalid: Drop Invalid"

/ipv6/firewall/raw> export 
add action=accept chain=prerouting comment="Prerouting: Accept unspecified for DAD from LAN" dst-address-list=ns_multicast icmp-options=135:0-255 in-interface-list=LAN protocol=icmpv6 src-address-list=unspecified
add action=accept chain=prerouting comment="Prerouting: Accept unspecified for MLD from LAN" dst-address-list=mld_multicast icmp-options=143:0-255 in-interface-list=LAN protocol=icmpv6 src-address-list=unspecified
add action=jump chain=prerouting comment="Prerouting: Jump to ICMPv6 chain" jump-target=icmpv6 protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: Drop MLD Query from WAN" icmp-options=130:0-255 in-interface-list=WAN protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: Drop MLDv1 Report from WAN" icmp-options=131:0-255 in-interface-list=WAN protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: Drop MLDv1 Done from WAN" icmp-options=132:0-255 in-interface-list=WAN protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: Drop MLDv2 Report from WAN" icmp-options=143:0-255 in-interface-list=WAN protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: Drop Node Information Query from WAN" icmp-options=139:0-255 in-interface-list=WAN protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: Drop Extended Echo Request from WAN" icmp-options=160:0-255 in-interface-list=WAN protocol=icmpv6
add action=return chain=icmpv6 comment="ICMP: Back to Prerouting"

/ipv6/firewall/filter> export where chain=input 
add action=jump chain=input comment="Input: Jump to Invalid" connection-state=invalid jump-target=invalid
# ... a bunch of accepts
add action=accept chain=input comment="Input: Accept ICMPv6" protocol=icmpv6
add action=reject chain=input comment="Input: Reject All from LAN" in-interface-list=LAN reject-with=icmp-admin-prohibited
add action=drop chain=input comment="Input: Drop All"

/ipv6/firewall/filter> export where chain=forward 
add action=jump chain=forward comment="Forward: Jump to Invalid" connection-state=invalid jump-target=invalid
add action=jump chain=forward comment="Forward: Jump to ICMPv6" jump-target=icmpv6 protocol=icmpv6
# ... a bunch of accepts
add action=reject chain=forward comment="Forward: Reject All from LAN" in-interface-list=LAN reject-with=icmp-admin-prohibited
add action=drop chain=forward comment="Forward: Drop All"

/ipv6/firewall/filter> export where chain=icmpv6  
add action=drop chain=icmpv6 comment="ICMP: (RFC4890) Drop hop-limit=1" hop-limit=equal:1 protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: (RFC4890) Drop Renumbering " icmp-options=138:0-255 protocol=icmpv6
add action=accept chain=icmpv6 comment="ICMP: (RFC4890) Accept Node Information Query from LAN" icmp-options=139:0-255 in-interface-list=LAN protocol=icmpv6
add action=drop chain=icmpv6 comment="ICMP: (RFC4890) Drop Node Information Query" icmp-options=139:0-255 protocol=icmpv6
add action=accept chain=icmpv6 comment="ICMP: Accept All"

/ipv6/firewall/filter> export where chain=invalid 
add action=accept chain=invalid comment="Invalid: Accept Invalid FIN" protocol=tcp tcp-flags=fin
add action=accept chain=invalid comment="Invalid: Accept Invalid RST" protocol=tcp tcp-flags=rst
add action=accept chain=invalid comment="Invalid: Accept Invalid FIN,ACK" protocol=tcp tcp-flags=fin,ack
add action=reject chain=invalid comment="Invalid: Reject Invalid TCP from LAN" in-interface-list=LAN protocol=tcp reject-with=tcp-reset
add action=reject chain=invalid comment="Invalid: Reject Invalid from LAN" in-interface-list=LAN reject-with=icmp-admin-prohibited
add action=drop chain=invalid comment="Invalid: Drop Invalid"

/ipv6/firewall/address-list> export where list=unspecified      
add address=::/128 disabled=no dynamic=no list=unspecified

/ipv6/firewall/address-list> export where list=ns_multicast 
add address=ff02::1:ff00:0/104 dynamic=no list=ns_multicast

/ipv6/firewall/address-list> export where list=mld_multicast 
add address=ff02::16/128 comment="MLDv2 Report multicast" dynamic=no list=mld_multicast

I prefer ( for home scenario)
/ip firewall filter
add chain=input action=accept protocol=icmp

Works, allows router functionality and has never caused me issues.
What burns my gut is when the ISP blocks ICMP so I cant test things easily.

Perhaps the prose and beauty config above is standard or more applicable in a business environment??