Skip to content

Feature request: display sets that match IP #7

@fraternl

Description

@fraternl

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions