I have a static IP on my router. My PC runs apache on localhost. When I open www.whatsmyip.org in my browser I get the static IP I was assigned from my ISP. When I run

<?php
echo file_get_contents("http://www.whatsmyip.org"); 

in apache from browser, on my PC's localhost server, it shows a different IP every time I run it. Where's the issue? my ISP? my apache config? the way get_file_contents works on URLs?

有帮助吗?

解决方案

This is funny one. It took me a while, but enjoyed it.

The source for that site contains:

<div>
    <!-- Please DO NOT use this site to power an IP bot, script or other IP-lookup software! -->
    <h1>Your IP Address is <span id="ip">a random ip</span></h1>
</div>

It is kind of anti bot mechanism (they even warn about it :D ). On page load it's replaced by your actual IP using Java Script.

I checked other sites and most of them use similar mechanism.

This one does not if you need to check http://whatsmyip.net/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top