Site-wide Tags:  Linux(17) | CommandLine(12) | Ubuntu(10) | RemoteAccess(7) | Tools(7) | Vim(7) | LiftWeb(5) | SBT(5) | SoftwareDev(5) | Mac(5) | Scripts(4) | WebDev(4) | Diagrams(4) | Lifty(3) | NetworkDrives(3) | Processwire(3) | Security(3) | Fog(3) | VCS(3) | BestPractices(3) | RaspberryPi(2) | WebDesign(2) | Encryption(2) | Windows(2) | SSH(2) | WinCommandPrompt(2) | GitHubRepos(2) | Emacs(2) | PHP(2) | IDE(2) | ErrorMsgs(2) | JVM(2) | Hardware(2) | Bash(2) | Networks(2) | Graphviz(2) | Cloning | Cygwin | Graphics | Java | SystemRecovery | lessc | Maven | Python | PXE | Samba | LXDE | PackageManagement | LifeHacks | LESS |

This site has been archived and will no longer be updated.
You can find my new profile at neilpahl.com. My new blog is at 808.ninja.

Host Your Own [What is my IP] Page

Tags:  Tools   PHP   
Created on Thu, 03 May 2012.

Motivation Behind This Cheatsheet

whatismyip.org used to return pure text containing only you external IP. Now, they use an image, which I can no longer parse with the scripts use to find out my external ip

The Cheatsheet

Your external IP can only be seen from a host outside your Local Area Network (LAN). Sure, you can see your ip using ifconfig (linux) and ipconfig (win) and it will tell you your ip is something like 192.168.1.x .But, this is only the ip accessible from within your LAN (accessible by computers within your network).

You can find your external ip by going to whatismyip.org or whatismyip.com and they will show you your ip. However, those sites are filled with other things which make it harder for a script to determine which part of the page is in fact the ip. whatismyip.org USED to return nothing but a short text string. Now, it return an image of the ip value. Perhaps someone abused their service?

Anyways, I use this ip string particularly in a script I used to email myself the ip of a host

Basically, all you have to do is host a php page containing only the following:

<?php 
 //Gets the IP address
 $ip = getenv("REMOTE_ADDR") ; 
 Echo $ip;
 ?>

name is something like myip.php and place it in your root web page folder so to access your ip, you can visit it through a URL like this:

www.myhost.com/myip.php



PLEASE let me know if I'm doing something wrong, or if you have any suggestions or requests~

blog comments powered by Disqus