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

后端 未结 13 1163
我寻月下人不归
我寻月下人不归 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:41

    Simple but not elegant for this use. I created a VBS file with the following code to drop the result to dropbox and google drive ... have to delete the file for new one to sync though for some reason.

    This runs on a PC at my home. My PC is set to resume on power outage and a task is scheduled to run this every day once (note if you have it run often, the site will block your requests).

    Now I can get my IP address on the road and watch people steal my stuff :-)

    get_html "http://ipecho.net/plain", "C:\Users\joe\Google Drive\IP.html"
    
    get_html "http://ipecho.net/plain", "C:\Users\joe\Dropbox\IP.html"
    
    
    
    sub get_html (up_http, down_http)
    
    dim xmlhttp : set xmlhttp = createobject("msxml2.xmlhttp.3.0")
    
    xmlhttp.open "get", up_http, false
    
    xmlhttp.send
    
    dim fso : set fso = createobject ("scripting.filesystemobject")
    
    dim newfile : set newfile = fso.createtextfile(down_http, true)
    
    newfile.write (xmlhttp.responseText)
    
    newfile.close
    
    set newfile = nothing
    set xmlhttp = nothing
    
    end sub
    

提交回复
热议问题