What’s my IP?

by keif on July 28, 2008

In my last post, I discussed how to block yourself from Google Analytics – but as Ms. Hill pointed out – how do you find your IP address? After all, how often are we directly connected to the internet – we’re behind corporate firewalls, routers, stolen Wi-Fi access – how do we know what we need to block?

Breaking it down Barney-Style: I just want my IP address!

Easy! There are a large number of sites that google will give to you – I’ve used http://whatismyip.com/ as it gives you what you’re looking for without being swarmed by ads (of course, I’m using Firefox…). This is the easiest way to grab your IP address if you’re unfamiliar with your router setup, network, etc. Go ahead – click it! You know you want to!

I’ve got a router. Screw this web site business!

Okay, smarty-pants, chill out. This is just as easy – access your router! Routers generally are accessed by going to the main IP – 192.168.x.1 – with x being any number, depending on your network. I’d suggest googling your router or looking in the manual for specifics (I love my Belkin router – the information is on the main page!)

What about getting the IP in Windows?

I’m assuming you’re using XP, because if not, you should be. This is really simple:

  1. Click Start -> Run.
  2. Type CMD – this brings up the “Command Line” and you can have some fun.
  3. Type “ipconfig” – normally this will give you your IP address, but if you’ve got a router…
  4. Type “ping -r 1 google.com” – this should give you a response of “Route:xxx.xxx.xx.xx” with your IP after the “Route:”

I’m a Mac user – where’s my IP?

This is a little easier on OS X.

  1. Go to Applications -> Utilities -> Network Utility -> Info
  2. That’ll give you your assigned IP.
  3. Uh, profit? I couldn’t find a way to get your actual IP – so youll have to go to your router’s web interface or a site above or…

I want a PHP page that tells me my IP.

Oh, hot stuff! The code is very simple. What’s your IP?

The code:

$ip=@$REMOTE_ADDR;
echo "<span style="font-family: Verdana; font-size: small;"><strong>IP Address= $ip</strong>";
</span>

Now, if you’re like me and have register_global set to off in your php.ini you need to change the script to get the address:

$ip=$_SERVER['REMOTE_ADDR'];

See? Simple!

  • Heh, that's exactly what kicked this off. I had commented out code on a client site and had to stop myself "there's got to be a better way" and also looking at my inflated numbers due to playing with the code a lot on the site...
  • Wow, thanks so much, Keith! Now, to see how much I was inflating my own #s...
blog comments powered by Disqus

Previous post:

Next post: