The great 127.255.255.255 IP enigma!
- 23 August, 2010 -
- PHP Coding -
- Tags : 127.255.255.255, BIGINT, INT, ip2long
- 2 Comments
Hi all,
few may have noticed I’ve been rather quiet on my blog lately but I have the best excuse! I’ve been extremely busy working on an important project.
Topic of the day: the weird 127.255.255.255 IP I found in my system’s access log.
I have a MySQL table with a signed INT temporarily storing ip2long processed IPs of visitors. The ip2long function converts an IP into a number that can be stored and queried very simply using basic SQL.
The problem is, signed INT can only store numbers between 2147483647 and -2147483647. 2147483647 is trhe numerical representation of the IP 127.255.255.255. This doesn’t mean that someone from that IP connected to my site. It means that someone with an IP that translated to a higher number connected and I stored it in a too short field.
I altered my INT into a BIGINT and voila!
References:
http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html
I hope this helps at least one confused fellow developer out there.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.
Consider http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-aton.
Yep, interesting too, especially considering it’s compatible with the inet_aton and inet_ntoa mysql functions. Good point.