I've updated grepcidr again, adding some code contributed by a user. (This open source thing may actually have a future.) grepcidr is what it sounds like, you give it a bunch of CIDR ranges, and files to read, and it prints out the lines in the files that contain addresses that match any of the CIDR ranges. The new feature lets it match CIDR ranges in the input files as well as IP addresses. It handles both IPv4 and IPv6. It maps each file into memory and runs a state machine over the file in one pass so it's quite fast. There should be no limits on line length, file size, or number of patterns other than running out of memory. Find it here: http://www.taugh.com/grepcidr-2/ Regards, John Levine, johnl@iecc.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. http://jl.ly
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 Hi John, Great contribution. Thanks Might I make a suggestion? with the following command it gives Invalid CIDR. In my usage it would seem logically convenient to throw any quad octet at it and have it translate to the proper CIDR range that isn’t reported as invalid since it does this anyway. For instance 127.0.0.1/8 would just become 127.0.0.0/8. Then add a (-d) flag for debugging or verbose messages. My first impression of the output was that it was only going to grep for valid CIDR ranges which was not true. $ cidr 127.0.0.1/8 Invalid cidr: 127.0.0.1/8 $ grepcidr -q 192.0.0.1/24 Invalid cidr: 192.0.0.1/24 All-in-all great tool and putting it to use right away! Thank you John On Jun 9, 2015, at 11:27, John Levine <johnl@iecc.com> wrote: I've updated grepcidr again, adding some code contributed by a user. (This open source thing may actually have a future.) grepcidr is what it sounds like, you give it a bunch of CIDR ranges, and files to read, and it prints out the lines in the files that contain addresses that match any of the CIDR ranges. The new feature lets it match CIDR ranges in the input files as well as IP addresses. It handles both IPv4 and IPv6. It maps each file into memory and runs a state machine over the file in one pass so it's quite fast. There should be no limits on line length, file size, or number of patterns other than running out of memory. Find it here: http://www.taugh.com/grepcidr-2/ Regards, John Levine, johnl@iecc.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. http://jl.ly - -- Jason Hellenthal JJH48-ARIN -----BEGIN PGP SIGNATURE----- iQEcBAEBCAAGBQJVd4OPAAoJEDLu+wRc4KcIKNYH/15qbVxyPhtcR3HnIXxEWzY+ hwLL0650Dr3cCxFAYkvNqcATgF8e3ZJTxDSKKs3jOlYTzGqQvMfbfI1AAMZyVuWD uyYDHP3SdQfzLlNclDAKZYHVdGNLVn76kew9k1R3uV8qdxfxtuRIhrko2bM60IxM dokeftVUafApnVU40O3mnHaDwAuoqWhKXZhMntNNrPRQqpwNoGfdiGMUtqTsDF6f XjTfY6Xtn3L6lzWK48PGqU6Tvj8/yKVR4BTMlfAp5UNqozYFl8nxfbfRBFEJDfDw JrlHpI52Z2n4d8zy/XKByWhiOskpPnm5QIxZHYXIfcvFA6nJSfl4J7ZiQvkkajE= =GuNx -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 In article <6DFDC9F9-EE28-4263-8E5B-EB751B35B2B4@dataix.net> you write:
Already does that with the -s for sloppy flag.
Find it here:
-----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlV38XsACgkQkEiFRdeC/kVMHQCfcy7D6fIrhIozpm2rwQ3C10g5 EOYAoKgARRkgkBy/+BRbMSKWd+fWWuaP =9isH -----END PGP SIGNATURE-----
participants (2)
-
Jason Hellenthal
-
John Levine