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)