Small “What-is-my-IP” script at ip.webernetz.net

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.:

 

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:
ip.webernetz.net_Wireshark

That’s it ;)

2 thoughts on “Small “What-is-my-IP” script at ip.webernetz.net

Leave a Reply

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