Find prefix based on ip-address #6787

Closed
opened 2025-12-29 19:45:23 +01:00 by adam · 3 comments
Owner

Originally created by @AndreasMoe on GitHub (Aug 9, 2022).

NetBox version

v3.2.7

Feature type

Change to existing functionality

Proposed functionality

When using https://cmdb.braathe.no/ipam/prefixes/ I can type in an IP address and find the corresponding prefix. In the API, I have tried to do the same, but returns all prefixes

In web
https://cmdb.braathe.no/ipam/prefixes/?q=10.xxx.x.xx - Returns the corresponding prefix
Any way to do this in API call?

In API

10.xxx.x.xx = IPaddress
10.yyy.y.y = Prefix
"https://cmdb.braathe.no/api/ipam/prefixes/?=10.xxx.x.xx" - returns all prefixes
"https://cmdb.braathe.no/api/ipam/prefixes/?prefix=0&=10.xxx.x.xx" - No response which is
"https://cmdb.braathe.no/api/ipam/prefixes/?prefix__isw=10.xxx" -returns all prefixes ( should return only matching?

Use case

Some imports , like Hyper-v get-vm does not give the subnet mask. If I can search for IP and find corresponding prefix, I can get the subnet mask and use this when importing data

Database changes

No response

External dependencies

No response

Originally created by @AndreasMoe on GitHub (Aug 9, 2022). ### NetBox version v3.2.7 ### Feature type Change to existing functionality ### Proposed functionality When using https://cmdb.braathe.no/ipam/prefixes/ I can type in an IP address and find the corresponding prefix. In the API, I have tried to do the same, but returns all prefixes In web https://cmdb.braathe.no/ipam/prefixes/?q=10.xxx.x.xx - Returns the corresponding prefix Any way to do this in API call? In API 10.xxx.x.xx = IPaddress 10.yyy.y.y = Prefix "https://cmdb.braathe.no/api/ipam/prefixes/?=10.xxx.x.xx" - returns all prefixes "https://cmdb.braathe.no/api/ipam/prefixes/?prefix=0&=10.xxx.x.xx" - No response which is "https://cmdb.braathe.no/api/ipam/prefixes/?prefix__isw=10.xxx" -returns all prefixes ( should return only matching? ### Use case Some imports , like Hyper-v get-vm does not give the subnet mask. If I can search for IP and find corresponding prefix, I can get the subnet mask and use this when importing data ### Database changes _No response_ ### External dependencies _No response_
adam closed this issue 2025-12-29 19:45:23 +01:00
Author
Owner

@jahknem commented on GitHub (Aug 9, 2022):

Did you try: /api/ipam/prefixes/?contains=10.xxx.x.xx ?
That works for me, although it returns a list of all prefixes which contain the IP

Edit: You can take a look at all possible API Requests in {{base_url}}/api/docs/

@jahknem commented on GitHub (Aug 9, 2022): Did you try: /api/ipam/prefixes/?contains=10.xxx.x.xx ? That works for me, although it returns a list of all prefixes which contain the IP Edit: You can take a look at all possible API Requests in {{base_url}}/api/docs/
Author
Owner

@AndreasMoe commented on GitHub (Aug 9, 2022):

Thank you so much, works like a charm :)

@AndreasMoe commented on GitHub (Aug 9, 2022): Thank you so much, works like a charm :)
Author
Owner

@jeremystretch commented on GitHub (Aug 9, 2022):

In the future, please open a discussion (rather than an issue) for questions like this.

@jeremystretch commented on GitHub (Aug 9, 2022): In the future, please open a discussion (rather than an issue) for questions like this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6787