<div dir="ltr"><div dir="ltr">This is what I have done using R:</div><div dir="ltr"><br></div><div dir="ltr"><a href="https://github.com/meekj/netblockr">https://github.com/meekj/netblockr</a><br></div><div dir="ltr"><br></div><div>I still use similar tools in Perl with Net::Netmask</div><div><br></div><div>Jon</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Oct 2, 2020 at 11:50 AM Royce Williams <<a href="mailto:royce@techsolvency.com">royce@techsolvency.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">The recent thread on CIDR aggregation cleanup scripts reminds me that I'm looking for a similarly efficient implementation of a related tool. (I'm gearing up to write my own in Perl, but don't want to reinvent the wheel.)<div><br></div><div><div>I'd like a fast, Unix-pipeline-ready tool that *replaces* all IPs within that range with a supplied string, using a simple config file as input, and ideally with autodetection of IP-address "word" boundaries, as in:</div><div><br></div></div><div>$ cat cidr-replace.cfg</div><div><a href="http://105.170.75.0/24%7C%5BUnitel%5D" target="_blank">105.170.75.0/24|[Unitel]</a></div><div><a href="http://209.112.128.0/18%7C%5BACS%5D" target="_blank">209.112.128.0/18|[ACS]</a><br></div><div><a href="http://209.165.128.0/18%7C%5BGCI%5D" target="_blank">209.165.128.0/18|[GCI]</a><br></div><div><a href="http://192.0.2.0/24%7C%5BTEST-NET-1%5D" target="_blank">192.0.2.0/24|[TEST-NET-1]</a></div><div><a href="http://198.51.100.0/24%7C%5BTEST-NET-2%5D" target="_blank">198.51.100.0/24|[TEST-NET-2]</a></div><div><a href="http://203.0.113.0/24%7C%5BTEST-NET-3%5D" target="_blank">203.0.113.0/24|[TEST-NET-3]</a><br></div><div><br></div><div>$ echo "source,data1,data2,209.112.130.2,data3" | cidr-replace cidr-replace.cfg</div><div>source,data1,data2,[ACS],data3<br></div><div><br></div><div><br></div><div>And I know this is kludgy, but it would also be useful for quick-and-dirty work if it had a flag to "append" the string using a known delimiter, as in:</div><div><br></div><div><div>$ echo "source,data1,data2,209.112.130.2,data3" | cidr-replace --append ',' cidr-replace.cfg</div><div>source,data1,data2,209.112.130.2,[ACS],data3<br></div><div></div></div><div><br></div><div>(But I'm happy to hack that last functionality into an existing script.)</div><div><br></div><div></div><div>-- <br></div><div><div dir="ltr"><div dir="ltr"><div>Royce</div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div></div>