My computers are sitting behind a router/firewall. How do I programmatically find out what my external IP address is. I can use http://www.whatsmyip.org/ for ad-hoc queries, but the TOS don't allow for automated checks.
Any ideas?
There's nothing in a normal request that would indicate internal or external origin. All you have to go on is the ip address sent in the request. To see if an IP is on the same network, you take your subnet mask and perform a bitwise AND with your own IP.
http://ipecho.net/plain appears to be a workable alternative, as whatismyip.com now requires membership for their automated link. They very kindly appear to be offering this service for free, so please don't abuse it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With