netbox-agent
netbox-agent copied to clipboard
Guess primary address
Netbox has the ability to flag an IP as Primary address
for a Device
Since it's tied to the user workflow, I'd say we could enable this guess with a config argument and use the following workflow
- parse the route table
- find the source ip of the default route
- flag this IP as
Primary adresss
interface = netifaces.gateways()['default'][netifaces.AF_INET][1]
will tell you which interface has the default route.
Doesn't seem to handle every case:
>>> import netifaces
>>> netifaces.gateways()
{'default': {}}
In my case IP are announced via exabgp