Third party cookies may be stored when visiting this site. Please see the cookie information.

Penguin Fortress YouTube Channel

What's my IP address?

Sometimes you need to know your IP address. Sometimes it needs to be the real IP address that you appear as on the Internet and not just the fake one that your local router uses. An example is when I blocked access from visitors whilst upgrading my blog.

Public vs. private IP addresses

First thing is you need to understand the different between public and private IP addresses to know which address you should be looking for. It's explained in detail in the Networking reference guide, but I'm guessing you'd rather have it condensed down to less than 5000 words.

Basically put your IP address is a string of numbers that identifies your computer on the Internet. When you are going to a website such as www.penguintutor.com that name is translated into the IP address (currently 213.171.218.150) and that's where your request goes to. The problem is that we are running out of addresses and in some cases (eg. for security reasons) you may want to hide behind a local IP address.
There are some addresses that are reserved for private address ranges which are:

Class A10.0.0.0         to        10.255.255.255
Class B172.16.0.0       to        172.31.255.255
Class C192.168.0.0      to        192.168.255.255

If you are using a home router rather than connecting directly to a ADSL/Cable Modem then you will most likely be given a private IP address from one of the ranges above and your computer will appear to be from the Internet IP address of the router when connecting to a site on the Internet.

If you are wanting to connect to a local machine on the same network (eg. to share files between computers on the same wireless network) then you normal need to know the local ip address. If however you are looking to add your IP address to a server on the Internet then you need to use the real Internet IP address.

Finding your local IP address on Linux

With Linux you can issue the ifconfig command. Then look for the address inet addr:


eth0      Link encap:Ethernet  HWaddr 00:1d:6c:3b:d4:a0  
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::20d:31ff:fe0d:d9a0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:755027 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1045478 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:118125432 (118.1 MB)  TX bytes:1268529451 (1.2 GB)
          Interrupt:16 Base address:0xa000 

Finding your local IP address on Windows

On Windows you can open a command prompt and run the command ipconfig.


Windows IP Configuration
Ethernet adapter Local Area Connection:
        Connection-specific DNS Suffix  . : penguintutor.com
        IP Address. . . . . . . . . . . . : 192.168.1.232
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.1.1

Finding your public IP address

If you need to find your public IP address then that will need to be done over the Internet. It is possible you may have a different proxy IP address to the address used for other protocols, and you could also have a proxy that gives different IP addresses per session but to keep it simple I'm assuming that the address you get to this server with is the same as the one you need.

You can check your ip address here:
PenguinTutor IP address checker - What's my IP address?

In this case the it's just 2 lines of PHP code which can be included in an appropriate php file on a webserver:


$ip=$_SERVER['REMOTE_ADDR'];
echo "$ip";

Note: This is all based on IPV4 which is what most of us are using when I wrote this. IPV6 has many more IP addresses and different private address ranges (see RFC4193).