http://www.perlmonks.org?node_id=127745


in reply to Getting net addy on localhost?

I want to get the correct IP address (and if possible, hostname) for my computer ... how do I get my real IP (which is currently 206.62.155.15)?

Since you say "currently", I'm going to assume that your address is assigned dynamically by your ISP/DSL/Cable provider.

The way I attack this problem is by periodically pinging a hidden CGI on my external web site. The CGI records the REMOTE_ADDR that pinged it, and responds with that REMOTE_ADDR. Then, from work, I can hit another hidden page on my site that tells me how recently my home machine reported in, and what IP address it used. (My DSL provider will drop the link after a few minutes of inactivity.) If the connection is still up, I can then reach it from the outside world.