Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Thomas Luening <toml@thlu.de>
To: netfilter@vger.kernel.org
Subject: Explanation of 2 Rules
Date: Sat, 22 Aug 2020 12:13:23 +0200	[thread overview]
Message-ID: <416b36ac-c17f-0ccd-3d28-cf8e4f3372ae@mail> (raw)

Hello @ all

Can anybody help me to explain und understand this 2 statements?
nft add rule ip filter input "tcp flags & (fin|syn|rst|psh|ack|urg) == fin|syn|rst|psh|ack|urg drop"
nft add rule ip filter input "tcp flags & (fin|syn|rst|ack) != syn ct state new drop"

That's what I think I understood....


TCP-Header first statement:
Bit          11  12  13  14  15  16
Type        URG ACK PSH RST SYN FIN
               0   0   0   0   1   0

             URG ACK PSH RST SYN FIN
XMAS          1   1   1   1   1   1

tcp flags & (fin|syn|rst|psh|ack|urg)  111111   = All flags are set (?) in Packet-Header, because  of   '&' = AND
fin|syn|rst|psh|ack|urg                111111   = Comparison to preprocessor directives = combined with '|' = OR

The result must be 111111 == 111111 to drop. Is that correct?



The second statement:
             URG ACK PSH RST SYN FIN
syn-chk       0   1   0   1   1   1

tcp flags & (fin|syn|rst|ack)           010111  = To much flags are set...
syn ct state new                                = ...because syn-flag is set and ct-state = new

The result must be (10111 != 000010 and ct new) to drop. Is that correct?


Thank you, best regards
Tom

             reply	other threads:[~2020-08-22 10:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-22 10:13 Thomas Luening [this message]
2020-08-24  9:39 ` Explanation of 2 Rules Thomas Luening
2020-08-26  6:49   ` kfm
2020-08-26 16:01     ` Thomas Luening
2020-08-26 17:28       ` kfm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=416b36ac-c17f-0ccd-3d28-cf8e4f3372ae@mail \
    --to=toml@thlu.de \
    --cc=netfilter@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox