A simple PHP script to tell a visitor's IP address and more information. This file is supposed to be on a webserver and can be configured by renaming
When the script is properly installed, one can visit/curl/wget the website to just receive one's public IP address. This is very useful in combination with other scripts (check out my snap-dyndns packages for example).
max@laptop ~> wget -qO - ip.nandus.net 220.127.116.11
Given the location of the script is
ip.example.com, you can also receive more information about the HTTP headers or the IP's reverse lookup:
REMOTE_ADDR: 18.104.22.168 HTTP_X_FORWARDED_FOR: 22.214.171.124 HTTP_USER_AGENT: Mozilla/5.0 (X11; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/50.0 HTTP_CLIENT_IP: HTTP_X_FORWARDED: HTTP_FORWARDED_FOR: HTTP_FORWARDED: HTTP_HOST: ip4.nandus.net HTTP_URI: HOSTNAME: p5B3E4401.dip0.t-ipconnect.de IPv4 REVERSE LOOKUP: 126.96.36.199
Ideal domain setup
In order to use IPv4- and IPv6-only domains, you'll have to have control over the DNS nameserver records of your own domain.
ip.example.comto be IPv4 (A Record) and IPv6 (AAAA Record) of your webserver
ip4.example.comto only be the IPv4 address
ip6.example.comto only be the IPv6 address
Make sure that the script is available through all those domains. Now your browser will use the default route for the
ip subdomain, and the v4 or v6 route for the respective subdomains