All of lore.kernel.org
 help / color / mirror / Atom feed
From: trentbuck@gmail.com (Trent W. Buck)
To: netfilter@vger.kernel.org
Subject: Re: Moving from ipset to nftables: Sets not ready for prime time yet?
Date: Wed, 08 Jul 2020 17:51:01 +1000	[thread overview]
Message-ID: <874kqih2ca.fsf@goll.lan> (raw)
In-Reply-To: a140ef1f-b238-3c8b-d8ec-3e266a893aea@thelounge.net

Reindl Harald <h.reindl@thelounge.net> writes:

> Am 03.07.20 um 09:04 schrieb G.W. Haywood:
>> On Fri, 3 Jul 2020, Timo Sigurdsson wrote:
>> 
>>> ... I use ipsets for blacklisting.
>>>     I fetch blacklists from various sources
>>> ... This approach has worked for me for quite some time.
>>> ... some of my blacklists may contain the same addresses or ranges,
>>>     I use ipsets' -exist switch when loading
>>> ... I don't think that the use case is that extraordinary ...
>> 
>> +6
>> 
>> FWIW I'll be following this thread very closely.
>
> it turned out at least with recent kernel and recent userland
> "iptables-nft" can fully replace "iptables" and continue to use "ipset"
> unchanged

I tested this and you're right - it is working.  This surprised me!

I saw these "commented out" rules in iptables-translate, where
I (wrongly) assumed that meant the rule was completely inactive.

    bash5$ sudo ip netns add delete-me
    bash5$ sudo ip netns exec delete-me bash
    bash5# nft list ruleset
    bash5# ipset create xs hash:ip
    bash5# iptables-nft -N x
    bash5# iptables-nft -A x -m set --match-set xs dst
    bash5# iptables-nft-save
    # Generated by xtables-save v1.8.3 on Wed Jul  8 17:30:56 2020
    *filter
    :INPUT ACCEPT [0:0]
    :FORWARD ACCEPT [0:0]
    :OUTPUT ACCEPT [0:0]
    :x - [0:0]
    -A x -m set --match-set xs dst 
    COMMIT
    # Completed on Wed Jul  8 17:30:56 2020
    bash5# nft list chain filter x
    table ip filter {
            chain x {
                    # match-set xs dst counter packets 0 bytes 0
            }
    }

Testing shows it IS matching, so
the only limitation is you must create the ruleset using
iptables-nft-restore (old syntax) instead of
nft (new syntax).

    bash5# iptables-nft -A OUTPUT -m set --match-set xs dst -j REJECT
    bash5# ip link set dev lo up
    bash5# ip a add 127.0.0.1/8 brd + dev lo
    bash5# iptables-nft-save -c
    ⋮
    [0:0] -A OUTPUT -m set --match-set xs dst -j REJECT --reject-with icmp-port-unreachable
    ⋮
    bash5# ping -c1 127.0.0.1
    ping: sendmsg: Operation not permitted
    bash5# iptables-nft-save -c
    ⋮
    [2:196] -A OUTPUT -m set –match-set xs dst -j REJECT –reject-with icmp-port-unreachable
    ⋮
    bash5# nft list chain filter OUTPUT
    ⋮
                    # match-set xs dst counter packets 2 bytes 196 reject
    ⋮


  reply	other threads:[~2020-07-08  7:51 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02 23:18 Moving from ipset to nftables: Sets not ready for prime time yet? Timo Sigurdsson
2020-07-03  7:04 ` G.W. Haywood
2020-07-03 10:39   ` Reindl Harald
2020-07-08  7:51     ` Trent W. Buck [this message]
2020-07-08 10:16       ` Reindl Harald
2020-07-08 10:36         ` Pablo Neira Ayuso
2020-07-08 10:48           ` Reindl Harald
2020-07-09  4:40           ` Trent W. Buck
2020-07-14 13:27 ` Timo Sigurdsson
  -- strict thread matches above, loose matches on Subject: below --
2020-07-02 22:30 Timo Sigurdsson
2020-07-03  9:28 ` Stefano Brivio
2020-07-03 10:24   ` Jozsef Kadlecsik
2020-07-03 13:38     ` Stefano Brivio
2020-07-03 14:03   ` Timo Sigurdsson
2020-07-30 19:27 ` Pablo Neira Ayuso

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=874kqih2ca.fsf@goll.lan \
    --to=trentbuck@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.