Sunday, June 13, 2021

Simple script to get subnet ID given an IP and mask

This seems like a simple enough thing, but I wasn’t finding exactly what I was looking for in my Google searching - I’m wondering if anyone has or knows of a CLI script (bash, python, or other) that, given an IP address and a mask, will return the subnet ID of that address. For example, given something like

192.168.200.199,255.255.255.192 I’d want it to give back

192.168.200.192

I know there are a lot of subnetting calculators online that will do this, but I’m looking to do this with a bunch of different interfaces, so having something I can just feed a CSV or stdin to would be a lot easier would be a lot easier than plugging them in one at a time. Just want to see if something like this already exists before I try to write it myself.



No comments:

Post a Comment