[racktables-users] Re: IP 4 calculation

  • From: John Lockard <jlockard@xxxxxxxxx>
  • To: "Lokkerbol, Cliff" <lokkerbolc@xxxxxxxxxxxxxxxxxxxxxxx>
  • Date: Thu, 17 Nov 2011 17:06:30 -0500

http://sqlserver2000.databases.aspfaq.com/how-should-i-store-an-ip-address-in-sql-server.html
http://php.net/manual/en/function.long2ip.php

Basically you're using division with remainders.

167908620 / (256*256*256) = 10 R 136460
136460 / (256*256) = 2 R 5388
5338 / (256) = 21 R 12

10.2.21.12

or

ip1 = ip / 16777216 
ip =  ip % 16777216 
ip2 = ip / 65536 
ip =  ip % 65536 
ip3 = ip / 256 
ip =  ip % 256 
ip4 = ip 

-John

On Thu, Nov 17, 2011 at 09:04:39PM +0000, Lokkerbol, Cliff wrote:
> Hi,
> 
> I am in the process of writing some SQL to generate reports from Racktables. 
> My question is how to I calculate the IP from the IP column. So example how 
> to I get from 167908620 to 10.2.21.12?
> 
> Thanks
> Cliff
> This message was created by:
> Cliff Lokkerbol - System Support Specialist - Innovation I.T Services
> "Simply put, it is possible to have convenience if you want to tolerate 
> insecurity; but if you want security, you must be prepared for inconvenience."
> 
> 
> ________________________________________________________________________
> Any opinions expressed in this email are those of the individual and not 
> necessarily the company. The contents of this email and any attachments are 
> confidential to The Innovation Group PLC and are solely for use by the 
> intended recipient at the email address to which it has been addressed.
> 
> This email and any attachments may not be disclosed to or used by anyone 
> other than the intended recipient, nor may it be copied in any way.  If you 
> have received this email in error, please forward a copy of this email to 
> itsupport@xxxxxxxxxxxxxxxxxxxxxxx and then delete it from your system.
> 
> The Innovation Group PLC: Registered in England 3256771
> Registered Office: Yarmouth House 1300 Parkway Solent Business Park Whiteley 
> Hampshire PO15 7AE UK
> http://www.innovation-group.com
> 
> This email and any attachments has been swept for computer viruses. Neither 
> The Innovation Group PLC nor the sender accept any responsibility for 
> computer viruses once this email has been transmitted.

-- 
"If you take out the killings, Washington actually
 has a very, very low crime rate." - Marion Barry
-------------------------------------------------------------------
         John M. Lockard |  U of Michigan - School of Information
 Unix and Security Admin |      1214 SI North - 1075 Beal Ave.
      jlockard@xxxxxxxxx |        Ann Arbor, MI  48109-2112
 www.umich.edu/~jlockard |     734-615-8776 | 734-647-8045 FAX
-------------------------------------------------------------------
- The University of Michigan will never ask you for your password -

Other related posts: