I have a long(ish) set of rules in my routing table, and a list of ip addresses. I'm looking to end up with output like CSV data, with the first column being the ip addresses from the original list, the second column being the gateway that would be used to connect to that IP based on the rules currently in the routing table, and the third column being the device that would be used to connect.
I did think briefly about throwing together a script to get the routing data from
route -n and do this, but partway through thinking up a function to do the subnet math I couldn't help thinking that this particular wheel has probably already been invented and is out there somewhere.
Does anyone know what commands could do what I'm after?