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.

  • 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-MuseFeb 15 at 17:42
  • 1) I am looking for something like this. Do you have any examples. Thanks btw– AhmedRanaFeb 15 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-MuseFeb 15 at 18:02

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

    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.

      Your Answer

       
      discard

      By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

      Not the answer you're looking for? Browse other questions tagged or ask your own question.