Several years ago I built a little script to show my IP address, just as many other sites implement it. The difference to my script is that it doesn’t display any kind of commercial or other annoying stuff. Just the IP address and a few other information. The script is accessible under http://ip.webernetz.net.
The php script consists the following six lines:
Note that the “IP Address” field simply outputs the IP address from which your connection came, either IPv4 or IPv6. That is, if you have a native IPv6 connection, you will see your IPv6 address since modern operating systems prefer native IPv6 over IPv4. If you only have IPv4, this address will be shown. However, if you have a 6to4 IPv6 connection, your IPv4 will be shown since many operating systems will use a 6to4 connection only if no IPv4 connection to the server is available (which is the case on our server).
The “X-Forwarded-For” IP address value is only shown if there is a HTTP proxy in place that inserts the appropriate HTTP header. This might be seldom for many people. But since I am sometimes troubleshooting proxy environments, I find it useful to print the client (and further proxy) IP address in my script, too.
The complete php script looks as follows. It also has one header() set, which is for the cache-control to not cache the values by proxies, etc.:
header("Cache-Control: no-cache, no-store");
print "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\">
<tr><td align=\"center\"><strong>Attribute</strong></td><td align=\"center\"><strong>Value</strong></td></tr>
<tr><td>IP Address (either v4 of v6)</td><td>".$_SERVER['REMOTE_ADDR']."</td></tr>
<tr><td>X-Forwarded-For IP Address(es)</td><td>".$_SERVER['HTTP_X_FORWARDED_FOR']." </td></tr>
<tr><td>Browser (User Agent)</td><td>".$_SERVER['HTTP_USER_AGENT']."</td></tr>
<tr><td>Request Time (Unixtime)</td><td>" .$_SERVER['REQUEST_TIME'] ."</td></tr>
<tr><td>Request Time</td><td>" .date("d.m.Y H:i:s",$_SERVER['REQUEST_TIME']) ."</td></tr>
I use this little script not only for identifying my current Internet IP address, but also for basic network functionality tests. After an initial DNS query and response, the normal TCP-Handshake is performed: SYN, SYN-ACK, ACK. One HTTP GET request and the appropriate 200 OK follow (both with ACKs from the other side) and finally the TCP session is terminated with FIN, FIN-ACK, ACK:
That’s it ;)