Hello
I’m looking to translate this iptables script into mikrotik firewall rule, but having trouble with some policies:
///////////////////////////////////////////////////////////////////////////////
//
// iptables_tcp_flags_programs.cfg
//
///////////////////////////////////////////////////////////////////////////////
// BADFLAGS – log and drop bad flags
=iptables -N BADFLAGS
=iptables -A BADFLAGS -j LOG --log-prefix "IPT BADFLAGS: " =logopt
=iptables -A BADFLAGS -j DROP
///////////////////////////////////////////////////////////////////////////////
// TCP_FLAGS – check tcp flags
=iptables -N TCP_FLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ACK,FIN FIN -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ACK,PSH PSH -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ACK,URG URG -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags FIN,RST FIN,RST -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags SYN,FIN SYN,FIN -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags SYN,RST SYN,RST -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ALL ALL -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ALL NONE -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ALL FIN,PSH,URG -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ALL SYN,FIN,PSH,URG -j BADFLAGS
=iptables -A TCP_FLAGS -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j BADFLAGS
///////////////////////////////////////////////////////////////////////////////
In iptables these are a little weird, for example ACK, FIN FIN is equal to Mikrotik tcp-flags=!ack,fin, but having issues with some others, if you know how to translate these rules and want to share it you are very welcome.
These are nice rules to filter invalid TCP flags and avoid some kind of attacks and invalid traffic, some are already dropped by mikrotik invalid policy, but I do not think all are dropped