How to Get the IP Address of Website Visitors

By | 2013-09-02

Now, now. I know most of you are pretty seasoned veterans of technology, and some of you are even top-notch developers. Would you believe someone out there is selling this, though? Yes, I know. On a particular forum for webmasters and SEO-type folks that I frequent, I saw a marketplace post for a script for sale. The script provided the functionality of revealing the IP address of visitors of your website. And what was he charging for this free information? Eleven US dollars.

WTF?!

Yep, this guy actually has the chutzpah to attempt to charge people for free information. Well, you know I can’t just let that stand. So, I’m going to show you how.

Why Should I Know the IP Address of Visitors?

Well, in all honesty, there is no real reason for you as a webmaster to know this information. The only time you’d need to know is if you get a subpoena from legal authorities for an investigation. And then their going to ask for your log files, filtered by a specific IP address. But lets say you’re building your own analytics type engine. Or maybe you want to watch for a certain IP address to pop up on your site. Maybe you might want to kick off a certain chain of events of you get a hit from a particular netblock. Most of time, these scripts are used for “What’s My IP Address?” type pages. Heck, fortypoundhead.com has one, located here. So here is the code. All one line of it. Just for kicks, two different language interpreters.

PHP

$ip=$_SERVER['REMOTE_ADDR'];

ASP

<% =Request.ServerVariables("REMOTE_ADDR") %>

Easy, huh? Now don’t go paying money for information that is free. Use your favorite search engine, and save some cash. You can buy me a beer next time you are in town.

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.