Assuming it is an IPv4 address, you could store it as a BIGINT if you converted it to a decimal form first, however, it would probably be easier to use if you store it as a string, leaving it in dotted-decimal (normal) notation. (Further info on IPv4 formats available here:
As for getting the information, it will usually be stored in the REMOTE_ADDR field, and some proxy servers will also send the IP of their client and that may be stored in a variable as well. However, the information provided by proxy servers can vary quite a bit, if it exists at all, you may find this page helpful:
If a user is behind a proxy server that does not report the user's address or if the user is on a network that is using NAT and private addresses, there's not much you can do to get the user's actual address. That is, after all, the whole point of NAT and proxy servers.
It's difficult to say what is the best method for storing your IP addresses. That answer will depend a lot on what you intend to do with them once they're in the database.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.