Skip to content

Add new field for IP netmask#21

Open
sebix wants to merge 7 commits into
DINA-community:Netbox_V4.2from
sebix:netmask-18
Open

Add new field for IP netmask#21
sebix wants to merge 7 commits into
DINA-community:Netbox_V4.2from
sebix:netmask-18

Conversation

@sebix

@sebix sebix commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

It's not well tested; therefore, it's a draft. Creating with a divergent netmask already works.

fixes #18

@Crubumble Crubumble self-requested a review April 11, 2025 20:53
@Crubumble Crubumble added the enhancement feature or request label Apr 11, 2025
@sebix

sebix commented Apr 12, 2025

Copy link
Copy Markdown
Contributor Author

I'm not sure yet about the wording. "IP Network" or "IP Netmask"?

What values should it accept? I now implemented the CIDR notation because it is the simplest variant. We could also accept a leading /. Should we also accept netmask notations (255.255.255.0)?

Successfully tested so far:

  • Add single device finding
  • Edit Device finding
  • Std Import (NMAP)
  • Import (CSV)
  • Create Device based on DeviceFinding
  • View Device Finding
  • Table view of device findings
  • Split Selected
  • Export (CSV)

@sebix

sebix commented Apr 18, 2025

Copy link
Copy Markdown
Contributor Author

Validation now removes a leading / and makes sure the netmask is >= 0 and <= 32.

Tested for: Mapping import (NMAP), Std Import (CSV), Add Device Finding and Edit Device Finding

@sebix

sebix commented Apr 18, 2025

Copy link
Copy Markdown
Contributor Author

Thinking about the naming again: I think ip_network is better, in line with with wording ip_address and already implies the CIDR notation.

Comment thread plugins/d3c/models.py Outdated
verbose_name='IP Address'
)
ip_netmask = models.CharField(
max_length=1000,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not a more reasonable value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because most other fields like IP addresse and mac address also have a maximum length of 1000. So, I used the existing convention.

@bernhardreiter

Copy link
Copy Markdown

Tested for

@sebix is it still "draft" or ready to merge?
(If it is ready, you can just change the status. If not: What is still to be done?)

@sebix

sebix commented May 5, 2025

Copy link
Copy Markdown
Contributor Author

Because of these:

It's not well tested; therefore, it's a draft.

Thinking about the naming again: I think ip_network is better, in line with with wording ip_address and already implies the CIDR notation.

@sebix

sebix commented May 5, 2025

Copy link
Copy Markdown
Contributor Author

And also this open question:

What values should it accept? I now implemented the CIDR notation because it is the simplest variant. We could also accept a leading /. Should we also accept netmask notations (255.255.255.0)?

@Crubumble

Copy link
Copy Markdown
Contributor

Since NetBox displays the CIDR notation. CDIR notation is sufficient for now. The nomenclature has to be decided. However it also can easily be changed later. The main reason for the draft status is that some aspects are missing, which I want to add myself in the pull request

@Crubumble

Copy link
Copy Markdown
Contributor

The problem with the missing netmask should be resolved right by the /findings/import/ and /findings/stdimport

in template findings_import:

  • is the IP address CIDR conform?
    is a netmask column given in the data? --> use it only for ip address where it is missing
  • possible to set a general netmask value (see template)
  • import findings with default 24 otherwise

Use of ipAddress with the common netbox display

  • show full ip address under findings and communication_finding
  • adjust the matching request/lookup as well

@sebix

sebix commented Aug 29, 2025

Copy link
Copy Markdown
Contributor Author

TODOs here:

  • If possible display the IP address and the netmask in one column as in /ipam/ip-addresses/
  • extract the IP netmask from the IP address if given in the original data

@sebix sebix marked this pull request as ready for review September 7, 2025 19:33
@sebix

sebix commented Sep 7, 2025

Copy link
Copy Markdown
Contributor Author

If possible display the IP address and the netmask in one column as in /ipam/ip-addresses/

The IPAM module has one field for IP address + netmask, so this was not a reference for the code.
Implemented for all tables, based on https://django-tables2.readthedocs.io/en/latest/pages/custom-data.html#subclassing-column

extract the IP netmask from the IP address if given in the original data

Implemented as well, tested for add, edit, import and stdimport

@sebix sebix removed their assignment Sep 7, 2025
sebix and others added 7 commits September 9, 2025 16:33
Validation now removes a leading `/` and makes sure the netmask is >= 0 and <= 32.
Tested for: Mapping import (NMAP), Std Import (CSV), Add Device Finding and Edit Device Finding
if not given explicitly
for adding and editing a devicefinding, and import & stdimport
@sebix

sebix commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

Rebased on main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants