Re: [nftables/nft] nft equivalent of "ipset test"

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

 



U.Mutlu <um@xxxxxxxxxxx> wrote:
> Florian Westphal wrote on 10/17/23 23:35:
> > U.Mutlu <um@xxxxxxxxxxx> wrote:
> > > The "ipset" commandline tool has the "test" command
> > > for testing whether a given item (ie. an IP) is in a given set.
> > > Is there an equivalent for the "nft" commandline tool of nftables?
> > > I unfortunately couldn't find the answer in the manpage of nft.
> > 
> > nft "get element inet tablename setname { 1.2.3.4 }"
> 
> But isn't that printing the whole item on stdout?
> I just need to quickly test it only,
> ie. need just a return code of 0 or 1, or so,
> for use in a shell script (bash).

?

nft "get element inet t s { 1.2.3.4 }" > /dev/null 2>&1; echo $?
1
nft "add element inet t s { 1.2.3.4 }"
nft "get element inet t s { 1.2.3.4 }" > /dev/null 2>&1; echo $?
0



[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