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