I need to save the IP address in the most compact way, the search is not a concern. It should also be compatible with Windows, Linux and Mac using any DB (MySQL, SQLite, Postgres, etc.).
Thanks to ip2long () and the long2ip () function in PHP, I can convert the IP4 address to a small int field, not varchar (15) or whatever. The problem is that we are in the transition phase to IP6, which means that most existing best practices do not work, including features that do not work with IP6. Moreover, DB functions such as INET_ATON () and INET_NTOA () are not parameters here.
So, how do you store the IP address as INT (or any other compact format) in a way that will work on any system?
EDIT: In a stream, the Wrang-wrang pointer indicates the use of inet_ntop () and inet_ptop () for packing and unpacking IP4 or IP6. The problem is that they only work with Linux / Mac with PHP +5.1 (this is not a big problem) and on windows with +5.3 (which is).
If this is not a problem, is it their replacement for the varbinary (16) field, which was recommended in each database?
source share