Re: testing if a named set exists?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.



[Index of Archives]     [Linux Netfilter Development]     [Linux Kernel Networking Development]     [Netem]     [Berkeley Packet Filter]     [Linux Kernel Development]     [Advanced Routing & Traffice Control]     [Bugtraq]

  Powered by Linux