How to extend inbuilt modules

35 views
Skip to first unread message

Anesu Mukanya

unread,
Aug 16, 2021, 7:33:44 AM8/16/21
to NetBox
Hello i want to extend the dcim.site to ipam.ipaddresses. Is it possible if so how. I intent to create a link between the name of a site and  associated ip addresses. I notice there is a link between ipam.prefix to site i want to have a link between site and ipaddress.es How do i do this bit. thank you

Craig

unread,
Aug 16, 2021, 10:32:31 AM8/16/21
to NetBox
The IP would be inside of a parent prefix which you can then attach to the site.

Anesu Mukanya

unread,
Aug 16, 2021, 8:36:56 PM8/16/21
to NetBox
i see that is resourceful. im looking for something of this logic ====> ipam.ipaddress(dcim.site ) for which i can have a direct link between an IP address and a site which i can call from the api.

 The link provided when we set the site in the prefix will provide GUI data that cannot be used when we make an api call for an IP address /ipam/ipaddresses/ endpoint. 

Brian Candler

unread,
Aug 17, 2021, 2:11:55 AM8/17/21
to NetBox
If you want to link *individual* IP addresses to sites, I can see two approaches:

1. Add a custom field to IP address
2. Add a /32 prefix for each site - which you can easily query from the API.

However the second case currently has an issue where the GUI doesn't show addresses underneath a /32 prefix, see:
Depending on your use case, it may be better just to create a *prefix* of size /32 to assign to the site, and no IP address at all.

Anesu Mukanya

unread,
Aug 17, 2021, 3:23:51 AM8/17/21
to NetBox
setting prefix works fine however pulling the data from /ipam/ipaddresses/ endpoint site doesn't show up, it only shows up in /ipam/prefixes/ where i dont intent to use in from

Brian Candler

unread,
Aug 17, 2021, 9:55:30 AM8/17/21
to NetBox
You can simply change your query then.  If the IP address is w.x.y.z/32, and you know it belongs to a /32 prefix, then you just query for prefix w.x.y.z/32
Reply all
Reply to author
Forward
0 new messages