I know that I can test an IP against a set, but I would like to be able to only give an IP and let ipset return all the sets that match.
I wrote a wrapper that does this, but I think it would be useful if it supported this natively (and faster).
ipset setmatch 192.168.1.1
ipsetmatch
#!/bin/bash
TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX`
ipset -n list >${TMPDIR}/ipsets
while read IPSET ; do
ipset test ${IPSET} $1 2>/dev/null && echo ${IPSET}
done<${TMPDIR}/ipsets
rm -r ${TMPDIR}
I know that I can test an IP against a set, but I would like to be able to only give an IP and let ipset return all the sets that match. I wrote a wrapper that does this, but I think it would be useful if it supported this natively (and faster).
ipset setmatch 192.168.1.1
ipsetmatch