I wanted to calculate the default gateway from a CIDR. The ipaddr filter has an undocumented gateway/router option but it results in unexpected values.
Here is the responsible method:
def _gateway_query(v): if v.size > 1: if v.ip != v.network: return str(v.ip) + '/' + str(v.prefixlen)
How is this a gateway? It basically returns the given CIDR.
Since this is not documented it’s hard to guess what was the intention behind this.
I’d like to send a pull request to change this but first wanted ask what you think about it. My proposal would be to change the method to:
def _gateway_query(v): if v.size > 1: return str(netaddr.IPNetwork(str(v.ip) + '/' + str(v.prefixlen))[1])
I know the gateway could be anything and does not necessarily have to be the first IP of the network range. But still this more or less the default. What do you think?
Greetings,
Daniel