From: "Álvaro Neira Ayuso" <alvaroneay@gmail.com>
To: Michael <pistenflitzer@alpenjodel.de>,
netfilter user mailinglist <netfilter@vger.kernel.org>
Subject: Re: Problems to get started with nftables
Date: Fri, 13 Jun 2014 13:37:50 +0200 [thread overview]
Message-ID: <539AE28E.2040204@gmail.com> (raw)
In-Reply-To: <op.xiag4xyrdwu75w@alpenjodel.de>
Hello Michael
El 11/06/14 20:25, Michael escribió:
> Dear all,
>
> I have some problems, that might well be due to my lack of understanding
> nftables: My rules look like this:
>
> table filter {
> chain input {
> type filter hook input priority 0;
> icmp type { echo-request } limit rate 5/second counter accept
^^^^^^^^^^^^^^^^
It's a single element, you don't need to use a set. You can use the rule
like:
nft add rule filter input icmp type echo-request limit rate 5/second
counter accept
> }
> }
>
> table ip6 filter {
> chain input {
> type filter hook input priority 0;
> icmpv6 type { nd-neighbor-advert, nd-neighbor-solicit, nd-router-advert } ip6 hoplimit 255 counter log prefix "log1: " accept
> icmpv6 type { echo-request } limit rate 5/second counter accept
> }
> }
>
> table inet filter {
> chain input {
> type filter hook input priority 1;
> ct state { established, related } accept
^^^^^^^^^^^^^^^^^^^^^^^^
Also, you have used here a set but you can use the rule without the set,
like that:
nft add rule inet filter input ct state established, related counter accept
> ct state invalid counter log prefix "log2: " drop
> iif lo accept
> # udp sport bootps dport bootpc accept
> counter log prefix "log3: " drop
> }
>
> chain output {
> type filter hook output priority 1;
> ct state { new, established, related } accept
> ct state invalid counter log prefix "log4: " drop
> oif lo accept
> }
> }
>
>
> What I observe when I load these rules is that the accept in the log1 line is
> not enough to accept the packets. They are ultimately dropped in the log3
> rule. How do I get the packets through both rule chains?
Because you have a table inet and a table ip6. The table ip6 filter
sees the ip6 traffic and the table inet filter sees the ip4 and ip6
traffic. You have defined the priority of the first chain at 0 so
nftables checks the rules there and after nftables checks the rules
inside of the filter chain in inet.
I suggest you to use one singles filter table like inet.
>
> The second problem is in the
> # udp sport bootps dport bootpc accept
> line. I've seen examples with this syntax, but it's not accepted for me. What
> is the correct syntax to filter on both dport and sport? I've tried using and
> or &, but that didn't work either.
The rules is like that:
nft add rule filter input udp sport bootps udp dport bootpc accept
>
> And finally: Is there a way to match the destination mac address of an
> incoming packet?
You must to add a rule with ether like this:
nft add rule filter input ether daddr 20:16:d8:a2:59:33 counter
I hope that I have explained correctly and I have helped you
Regards
Álvaro
prev parent reply other threads:[~2014-06-13 11:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-11 18:25 Problems to get started with nftables Michael
2014-06-13 11:37 ` Álvaro Neira Ayuso [this message]
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=539AE28E.2040204@gmail.com \
--to=alvaroneay@gmail.com \
--cc=netfilter@vger.kernel.org \
--cc=pistenflitzer@alpenjodel.de \
/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;
as well as URLs for NNTP newsgroup(s).