netbox-agent icon indicating copy to clipboard operation
netbox-agent copied to clipboard

Guess primary address

Open Solvik opened this issue 5 years ago • 2 comments

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

Solvik avatar Aug 07 '19 16:08 Solvik

interface = netifaces.gateways()['default'][netifaces.AF_INET][1]

will tell you which interface has the default route.

ThomasADavis avatar Sep 06 '19 21:09 ThomasADavis

Doesn't seem to handle every case:

>>> import netifaces
>>> netifaces.gateways()
{'default': {}}

In my case IP are announced via exabgp

Solvik avatar Sep 07 '19 08:09 Solvik