List:General Discussion« Previous MessageNext Message »
From:Michael T. Babcock Date:February 11 2003 8:25pm
Subject:Re: IP Addresses -- How to Store
View as plain text  
On Tue, Feb 11, 2003 at 01:15:01PM -0500, Aaron Conaway wrote:
> I'm looking to develop a database of IP addresses for the company and
> have, of course, chosen mySQL as the backend.  I want the app to add
> (remove, etc.) a host, giving its hostname and segment.  The app will
> add the next available address to the database and, looking at the
> segment, provide the subnet mask and default gateway for said new host.
> I've got the db structure written out, but I'm having issues on how to
> store the data like address, subnet mask, default gateway.

Consider familiarizing yourself with bit-level network masking
math and then store your IP addresses as 16 bit long integer
values (until you're storing ipv6 addresses, of course).  Store
your network mask as either the 16 bit value of the mask or if
you care about space, a tinyint of how many bits are in the mask.
-- 
Michael T. Babcock
CTO, FibreSpeed Ltd.     (Hosting, Security, Consultation, Database, etc)
http://www.fibrespeed.net/~mbabcock/
Thread
IP Addresses -- How to StoreAaron Conaway11 Feb
  • Re: IP Addresses -- How to StoreDan Nelson11 Feb
    • Re: IP Addresses -- How to StorePeter Hicks11 Feb
  • Re: IP Addresses -- How to StoreMichael T. Babcock11 Feb
  • Re: IP Addresses -- How to StorePeter Grigor11 Feb
    • Re: IP Addresses -- How to StoreMichael T. Babcock11 Feb
RE: IP Addresses -- How to StoreAaron Conaway11 Feb