Example Code

Programmatically obtain Public IP Address

Code and Documents

Attachment

Overview
 This example vi is used to obtain the public IP address of the mechine.

 


Description
This example code shows how you can use the included HTTP Client VI in LabVIEW to obtain the Public IP address of the machine it is running on. It accomplishes this by simply doing a Google search for the term "What is my IP". If you search for the same term in a browser Google will return your public IP address at the top of the search results. Then the vi simply parses the html that is returned and extracts that IP address so that it can be used in your code.

 


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Download the attached folder to your computer
  2. Open the VI "Get Public IP From Google 2012 NIVerified.vi"
  3. Run the VI

 

Additional Information or References
VI Snippet

Block Diagram.PNG

 

  **This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
T.Minami
NI Employee (retired)
on

I recently tried running this VI from Japan, and it returned nothing because of Google trying to redirect me to google.co.jp... I instead tried contacting http://whatismyipaddress.com/ and parsing the http document returned by this page, which worked like a charm!

I've attached LV snippets for LV2014, in case anybody is interested.

Get_Public_IP_From_whatismyipaddress_LV2014.png