From: Duncan Roe <duncan_roe@optusnet.com.au>
To: Matt Zagrabelny <mzagrabe@d.umn.edu>
Cc: Netfilter <netfilter@vger.kernel.org>
Subject: Re: testing if a named set exists?
Date: Sat, 2 Oct 2021 12:52:45 +1000 [thread overview]
Message-ID: <YVfJfRVCARWtZVCI@slk1.local.net> (raw)
In-Reply-To: <CAOLfK3UBEvRg8AQbLibVo9xp6tZjaE7_S1+uDyhhbR7Nj_eYhA@mail.gmail.com>
On Fri, Oct 01, 2021 at 08:16:17PM -0500, Matt Zagrabelny wrote:
> Hello,
>
> I'd like to do something like the following:
>
> if exists $named_set
> nft add rule ip filter output ip daddr $named_set accept
> else
> nft add rule ip filter output ip daddr $default_set accept
>
> Does anyone know if I can accomplish this with nftables?
>
> Thanks,
>
> -m
How about
> if nft list ruleset | grep -q "$named_set"; then
> nft add rule ip filter output ip daddr $named_set accept
> else
> nft add rule ip filter output ip daddr $default_set accept
> fi
You can restrict the search to a table, e.g. instead of "ruleset"
put "table $my_table"
Cheers ... Duncan.
next prev parent reply other threads:[~2021-10-02 2:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-02 1:16 testing if a named set exists? Matt Zagrabelny
2021-10-02 2:52 ` Duncan Roe [this message]
2021-10-02 2:57 ` Kerin Millar
2021-10-02 11:50 ` Matt Zagrabelny
2021-10-02 23:50 ` 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=YVfJfRVCARWtZVCI@slk1.local.net \
--to=duncan_roe@optusnet.com.au \
--cc=mzagrabe@d.umn.edu \
--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