Request: Find parent subnets of searched IP #4527

Closed
opened 2025-12-29 18:36:59 +01:00 by adam · 2 comments
Owner

Originally created by @gramathy on GitHub (Feb 2, 2021).

Environment

  • Python version:
  • NetBox version: v2.10.3

Proposed Functionality

When searching for an IP address, also return prefixes the IP belongs to. This would provide additional information if individual IP information is lacking or the IP is part of a dynamic scope rather than individually recorded.

Use Case

A device is misbehaving or compromised and is initiating faulty requests. The individual IP is not recorded and a search returns nothing at the moment. Returning parent subnets would provide some information as to where the device might be located on large networks where not everyone might already know where all subnets are. (example: a testing subnet where the IPs would not typically be recorded for use). This should be similar to the behavior of searching for a parent prefix where all child prefixes of the searched prefix are returned.

Database Changes

none, should only require some masking math

External Dependencies

Originally created by @gramathy on GitHub (Feb 2, 2021). <!-- NOTE: IF YOUR ISSUE DOES NOT FOLLOW THIS TEMPLATE, IT WILL BE CLOSED. This form is only for proposing specific new features or enhancements. If you have a general idea or question, please start a discussion instead: https://github.com/netbox-community/netbox/discussions NOTE: Due to an excessive backlog of feature requests, we are not currently accepting any proposals which significantly extend NetBox's feature scope. Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: * NetBox version: v2.10.3 <!-- Describe in detail the new functionality you are proposing. Include any specific changes to work flows, data models, or the user interface. --> ### Proposed Functionality When searching for an IP address, also return prefixes the IP belongs to. This would provide additional information if individual IP information is lacking or the IP is part of a dynamic scope rather than individually recorded. <!-- Convey an example use case for your proposed feature. Write from the perspective of a NetBox user who would benefit from the proposed functionality and describe how. ---> ### Use Case A device is misbehaving or compromised and is initiating faulty requests. The individual IP is not recorded and a search returns nothing at the moment. Returning parent subnets would provide some information as to where the device might be located on large networks where not everyone might already know where all subnets are. (example: a testing subnet where the IPs would not typically be recorded for use). This should be similar to the behavior of searching for a parent prefix where all child prefixes of the searched prefix are returned. <!-- Note any changes to the database schema necessary to support the new feature. For example, does the proposal require adding a new model or field? (Not all new features require database changes.) ---> ### Database Changes none, should only require some masking math <!-- List any new dependencies on external libraries or services that this new feature would introduce. For example, does the proposal require the installation of a new Python package? (Not all new features introduce new dependencies.) --> ### External Dependencies
adam closed this issue 2025-12-29 18:36:59 +01:00
Author
Owner

@sdktr commented on GitHub (Feb 4, 2021):

Isn't this the behavior in the GUI already? If a non-existing IP is searched for you'll get the prefixes that match most of the bits in the address as a result?

@sdktr commented on GitHub (Feb 4, 2021): Isn't this the behavior in the GUI already? If a non-existing IP is searched for you'll get the prefixes that match most of the bits in the address as a result?
Author
Owner

@jeremystretch commented on GitHub (Feb 4, 2021):

You can use the ?contains= filter on the prefixes list and API endpoint to return all prefixes that contain (or would contain) a given IP address, whether or not that IP actually exists.

@jeremystretch commented on GitHub (Feb 4, 2021): You can use the `?contains=` filter on the prefixes list and API endpoint to return all prefixes that contain (or would contain) a given IP address, whether or not that IP actually exists.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4527