grepcidr — Filter IP addresses matching IPv4 CIDR/network specification
grepcidr [-V] [-c] [-v] [-e pattern | -f file]
This manual page documents briefly the grepcidr command.
This manual page was written for the Debian distribution because the
original program does not have a manual page.
grepcidr can be used to filter a list of IP addresses against one or
more Classless Inter-Domain Routing (CIDR) specifications, or arbitrary
networks specified by an address range. As with grep, there are options
to invert matching and load patterns from a file. grepcidr is capable
of comparing thousands or even millions of IPs to networks with little
memory usage and in reasonable computation time.
-V Show software version
-c Display count of the matching lines, instead of showing the
-v Invert the sense of matching, to select non-matching IP
-e Specify pattern(s) on command-line
-f Obtain CIDR and range pattern(s) from file
grepcidr -f ournetworks blocklist > abuse.log
Find our customers that show up in blocklists
grepcidr 127.0.0.0/8 iplog
Searches for any localnet IP addresses inside the iplog file
grepcidr "192.168.0.1-192.168.10.13" iplog
Searches for IPs matching indicated range in the iplog file
script | grepcidr -vf whitelist > blacklist
Create a blacklist, with whitelisted networks removed (inverse)
grepcidr -f list1 list2
Cross-reference two lists, outputs IPs common to both lists
This manual page was written by Ryan Finnie firstname.lastname@example.org for the
Debian system (but may be used by others). Permission is granted to
copy, distribute and/or modify this document under the terms of the GNU
General Public License, Version 2 any later version published by the
Free Software Foundation.
On Debian systems, the complete text of the GNU General Public License
can be found in /usr/share/common-licenses/GPL.