Guess primary address #23

Open
opened 2019-08-07 18:24:00 +02:00 by Solvik · 2 comments
Solvik commented 2019-08-07 18:24:00 +02:00 (Migrated from github.com)

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
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`
ThomasADavis commented 2019-09-06 23:30:50 +02:00 (Migrated from github.com)

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

will tell you which interface has the default route.

interface = netifaces.gateways()['default'][netifaces.AF_INET][1] will tell you which interface has the default route.
Solvik commented 2019-09-07 10:20:19 +02:00 (Migrated from github.com)

Doesn't seem to handle every case:

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

In my case IP are announced via exabgp

Doesn't seem to handle every case: ``` >>> import netifaces >>> netifaces.gateways() {'default': {}} ``` In my case IP are announced via exabgp
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: DGNum/netbox-agent#23
No description provided.