How do I find out what my external IP address is?

后端 未结 13 1173
我寻月下人不归
我寻月下人不归 2020-12-13 04:15

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,

13条回答
  •  没有蜡笔的小新
    2020-12-13 04:42

    If you have access to a webserver with modphp, you can roll your own:

    
    

    If you don't want that to get abused, you'll have to keep it secret or add request limits.

    I've been using one on my server for years.

    Explicitly:

    Create a file called whatismyip.php in your public_html folder in your website. It can be called anything and be anywhere in your webroot.

    Add the line above, and then query your server:

    curl http://example.com/whatismyip.php
    

    for example.

提交回复
热议问题