prefixes - store if prefix is public or private or other ip-space - allow filtering by ip space class #201

Open
opened 2026-04-05 16:22:56 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @ITJamie on 3/6/2026

NetBox version

v4.5.4

Feature type

Data model extension

Proposed functionality

when a prefix is created. calculate the prefix class and store it in a new field. allow filtering of prefixes by that new field. if not in the list below it should be considered Public

Private / internal addressing
	•	RFC1918 – Private IPv4 address space
	•	10.0.0.0/8
	•	172.16.0.0/12
	•	192.168.0.0/16

Carrier-grade NAT
	•	RFC6598 – Shared Address Space
	•	100.64.0.0/10

Loopback
	•	RFC1122 – IPv4 Loopback
	•	127.0.0.0/8

Link-local
	•	RFC3927 – IPv4 Link-Local
	•	169.254.0.0/16
	•	RFC4291 – IPv6 Link-Local
	•	fe80::/10

Documentation ranges
	•	RFC5737 – IPv4 Documentation Prefixes
	•	192.0.2.0/24
	•	198.51.100.0/24
	•	203.0.113.0/24
	•	RFC3849 – IPv6 Documentation Prefix
	•	2001:db8::/32

Multicast
	•	RFC5771 – IPv4 Multicast
	•	224.0.0.0/4
	•	RFC4291 – IPv6 Multicast
	•	ff00::/8

Benchmarking
	•	RFC2544 – Benchmark testing network
	•	198.18.0.0/15

Reserved / special use
	•	RFC6890 – Special-purpose IP address registries

Use case

When searching netbox prefixes it would be useful to be able to quickly filter down to types of addresses.

Eg during a recent audit of all prefixes. we wanted to be able to easily filter down to just public ranges to make sure all active public prefixes had a tenant assigned.

instead of a single search we had to do multiple rounds of searchs with the our public prefix container as the parent search

Database changes

add a read-only field eg "ip_space_class" or similar

backfill it in with a migration

import ipaddress

net = ipaddress.ip_network(prefix)

if net.is_private:
    ip_space_class = "private"
elif net.is_global:
    ip_space_class = "public"
elif net.is_loopback:
    ip_space_class = "loopback"
elif net.is_link_local:
    ip_space_class = "link_local"
elif net.is_multicast:
    ip_space_class = "multicast"

External dependencies

n/a

*Originally created by @ITJamie on 3/6/2026* ### NetBox version v4.5.4 ### Feature type Data model extension ### Proposed functionality when a prefix is created. calculate the prefix class and store it in a new field. allow filtering of prefixes by that new field. if not in the list below it should be considered Public ``` Private / internal addressing • RFC1918 – Private IPv4 address space • 10.0.0.0/8 • 172.16.0.0/12 • 192.168.0.0/16 Carrier-grade NAT • RFC6598 – Shared Address Space • 100.64.0.0/10 Loopback • RFC1122 – IPv4 Loopback • 127.0.0.0/8 Link-local • RFC3927 – IPv4 Link-Local • 169.254.0.0/16 • RFC4291 – IPv6 Link-Local • fe80::/10 Documentation ranges • RFC5737 – IPv4 Documentation Prefixes • 192.0.2.0/24 • 198.51.100.0/24 • 203.0.113.0/24 • RFC3849 – IPv6 Documentation Prefix • 2001:db8::/32 Multicast • RFC5771 – IPv4 Multicast • 224.0.0.0/4 • RFC4291 – IPv6 Multicast • ff00::/8 Benchmarking • RFC2544 – Benchmark testing network • 198.18.0.0/15 Reserved / special use • RFC6890 – Special-purpose IP address registries ``` ### Use case When searching netbox prefixes it would be useful to be able to quickly filter down to types of addresses. Eg during a recent audit of all prefixes. we wanted to be able to easily filter down to just public ranges to make sure all active public prefixes had a tenant assigned. instead of a single search we had to do multiple rounds of searchs with the our public prefix container as the parent search ### Database changes add a read-only field eg "ip_space_class" or similar backfill it in with a migration ``` import ipaddress net = ipaddress.ip_network(prefix) if net.is_private: ip_space_class = "private" elif net.is_global: ip_space_class = "public" elif net.is_loopback: ip_space_class = "loopback" elif net.is_link_local: ip_space_class = "link_local" elif net.is_multicast: ip_space_class = "multicast" ``` ### External dependencies n/a
Sign in to join this conversation.
No Label complexity: medium complexity: medium complexity: medium complexity: medium complexity: medium complexity: medium complexity: medium complexity: medium netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox netbox status: backlog status: backlog status: backlog status: backlog status: backlog status: backlog type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature type: feature
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#201