2

I have a requirement to make an app in Java which will manage IPv4 (or in future IPv6 too). The users will be managing their range of IP addresses, supernets and subnets (creating/deleting etc) in that app. I have a few questions about the architecture.

  1. What is the best format to store/search IPv4 and it's prefix in DB2 (considering I will be accessing them through Java)?

  2. They will also be using private IP address range too, e.g. 10.0.0.0/8, which creates 16777214 IP addresses. Out of these they will be using only 0.1% IPs when they try to create this network. How should I define this in DB? Should I create 16 million rows representing each IP or should I only create used IPs in DB?

I will be using DB2 10.5 with Java 1.6.

Tiago Mussi
  • 801
  • 3
  • 13
  • 20
AhmedRana
  • 486
  • 9
  • 22
  • For 1), the "best" thing to do is create a custom type that can parse/display the relevant text format, but actually stores it as an integer or 4. For 2), you want some way to store the start/end of the range, but I don't enough about how subnetting works to say whether that's an explicit end/start or something else. – Clockwork-Muse Feb 15 '18 at 17:42
  • 1) I am looking for something like this. Do you have any examples. Thanks btw – AhmedRana Feb 15 '18 at 17:49
  • Not offhand, it's not something I've tried on a database - you'd have to read the relevant documentation and any questions around here. – Clockwork-Muse Feb 15 '18 at 18:02

2 Answers2

0

simply use the text format , in java they use the string format and if you ant to deal wwith subnetwork ,,,et just some string funtion to extrat the filed you need

Ayoub Benayache
  • 1,046
  • 12
  • 28
0

As per this answer Maximum length of the textual representation of an IPv6 address?, you can use 45 as the length of column to store the IPv6 address that will also accomodate IPv4 since it is only 39 characters.

To answer your second question, you can only store those used IP address and indexed it by IP column itself such that retrieving is faster.

This is a general suggestion and not specific to any database.

royalghost
  • 2,773
  • 5
  • 23
  • 29