netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aleksey Nikapli <excusemysmile@gmail.com>
To: netfilter@vger.kernel.org
Subject: Problem with migration from iptables+ipset to nftables
Date: Tue, 11 Jun 2024 10:30:56 +0300	[thread overview]
Message-ID: <CACvpvYW6ybpkCcod5uTGXEODG2nByt4FWUK11rf=mGVLuhy9Aw@mail.gmail.com> (raw)

Hi!

I have a question regarding migration from ipset to nftables. I have
plenty of sets of this kind, containing tcp/udp/icmp:


ipset create MYSET hash:ip,port family inet hashsize 1024 maxelem 65536
ipset add MYSET 172.18.1.11,udp:137
ipset add MYSET 172.18.1.11,udp:138
ipset add MYSET 172.18.1.11,tcp:139
ipset add MYSET 172.18.1.11,tcp:445
ipset add MYSET 172.18.1.11,icmp:echo-request

and a firewall rule for it:


iptables -A FORWARD -s 10.1.20.150/32 -m set --match-set MYSET dst,dst -j ACCEPT

When I translate my set to nftables i get a set like this:


add set inet global MYSET { type ipv4_addr . inet_proto .
inet_service; size 65536; }
add element inet global MYSET { 172.18.1.11 . udp . 137 }
add element inet global MYSET { 172.18.1.11 . udp . 138 }
add element inet global MYSET { 172.18.1.11 . tcp . 139 }
add element inet global MYSET { 172.18.1.11 . tcp . 445 }
add element inet global MYSET { 172.18.1.11 . icmp . 2048 }


However, I can't use it in nft rule because it requires to select
protocol (tcp/udp) when selecting dport:

ip saddr . meta l4proto . tcp dport @MYSET accept

Is there a way to translate and use this kind of sets to nftables or
do i need to create three separate rules (for tcp, udp and icmp
respectively)?


Also another question is, is there some kind of list:set set type in
nftables? So i could make a set of sets and use it in the ruleset as I
could with iptables+ipset?


Thanks in advance.


Best regards,

Alex

             reply	other threads:[~2024-06-11  7:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-11  7:30 Aleksey Nikapli [this message]
2024-06-11  7:39 ` Problem with migration from iptables+ipset to nftables Kerin Millar

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='CACvpvYW6ybpkCcod5uTGXEODG2nByt4FWUK11rf=mGVLuhy9Aw@mail.gmail.com' \
    --to=excusemysmile@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 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).