Saturday, 25 August 2012

Fast way of getting your public IP address

There are many ways of getting your public IP address (which is assigned to you by your ISP). The fastest and easiest way to get your public IP address is by accessing icanhazip.com.

Other ways include:


All of the above should give you the same results.

If you do not want to use the browser, and prefer to use a saved script, copy and paste the flowing code snippet into a file with the .vbs extension (you could name the file get_public_ip.vbs).
Option Explicit
Dim http : Set http = CreateObject( "MSXML2.ServerXmlHttp" )
http.Open "GET", "http://icanhazip.com", False
http.Send
Wscript.Echo http.responseText   'or do whatever you want with it
Set http = Nothing

This script will get the public IP address from icanhazip.com.

To run the script, navigate to the folder holding issue the command at the command prompt (assuming the file name is get_public_ip.vbs):
cscript get_public_ip.vbs