zeek / pysubnettree

A Python Module for CIDR Lookups
Other
50 stars 20 forks source link

Over scribing ASN to same net but distinct mask #16

Open LMBertholdo opened 5 years ago

LMBertholdo commented 5 years ago

Apparently, when you put the longest prefix it over scribe all less specific.

t["10.1.0.0/22"] = "as10" t["10.1.0.0/24"] = "as20" print(t["10.1.0.0/22"], t["10.1.0.0/24"]) as20 as20

jsiwek commented 5 years ago

From the README, "Lookups are performed by longest-prefix matching." And maybe the confusing part is also that I don't think this is doing a lookup of the networks/keys:

print(t["10.1.0.0/22"], t["10.1.0.0/24"])

I think it's silently dropping the prefix length and essentially just doing:

print(t["10.1.0.0"], t["10.1.0.0"])

And the longest prefix match for that was "as20".

To get the list of prefixes that were originally inserted in the SubnetTree, might be able to use the prefixes() method:

>>> t.prefixes(ipv4_native=True)
{'10.1.0.0/22', '10.1.0.0/24'}