LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to change IP address settings dynamically?

Hi,

 

I need to change my PXI systems IP address dynamically using a LabVIEW VI. Would someone guide me how to do that, an example code would be appreciated 🙂

 

PXI system's operating system: Windows 7

LabVIEW version: LabVIEW 2014

 

Thank you

Adarsh

Adarsh
CLA - Certified LabVIEW

Architect
https://www.youracclaim.com/badges/4871da75-1b8b-422a-a881-9ab206d2d36d/public_url
0 Kudos
Message 1 of 6
(3,872 Views)

Use the System Exec.vi and pass the command netsh interface ipv4 set address “local area connection” static 192.168.1.2 255.255.255.0 192.168.1.254

 

Change as required for your IP address and subnet.

 

This is setting an 192.168.1.2 with subnet of 255.255.255.0 and gateway of 192.168.1.254.

0 Kudos
Message 2 of 6
(3,862 Views)

Hi Dave,

 

Thanks for the reply!

 

I have tried this but didn't work for me L

I have attached the vi I tried, let me know something else to be added to this.

 

Thank you

Adarsh

Adarsh
CLA - Certified LabVIEW

Architect
https://www.youracclaim.com/badges/4871da75-1b8b-422a-a881-9ab206d2d36d/public_url
0 Kudos
Message 3 of 6
(3,760 Views)

Well, your command string says "Local Area Connection", but the picture says "Local Area Connection 2".  Could that be the problem?

 

When you say "Change IP address settings dynamically", do you mean change the settings on your PC, or do you mean "find the IP of that device over there" (such as a PXI controller)?

 

BS

0 Kudos
Message 4 of 6
(3,739 Views)

Hi Bob, Thank you for the reply!

 

While highlighting i just highlighted "Local Area Connection 2".  Any ways I tried with both "Local Area Connection" and "Local Area Connection 2", it didn't work for me.

 When I say "Change IP address settings dynamically", I mean change the settings on the PC(where I run the VI).

 

Thank you

Adarsh

Adarsh
CLA - Certified LabVIEW

Architect
https://www.youracclaim.com/badges/4871da75-1b8b-422a-a881-9ab206d2d36d/public_url
0 Kudos
Message 5 of 6
(3,679 Views)

Hmm -- changing your IP "out from under you" might be a bit tricky.  I did a little experiment -- I opened a Command prompt and tried to change the IP of the interface associated with my PXI (I didn't want to mess with the one to the internet!).  The following sometimes, but not always, worked for me:

 

   netsh interface ipv4 set address "PXI Network" static 10.0.0.108 255.255.255

 

You might notice I didn't set a Gateway (not needed, as this is not being routed anywhere).  It did seem to make the change, but I sometimes had to dive into Windows' Network setting to see it.

 

I haven't tried to do this programmatically, but what one does with System Exec is essentially what one does at the Command prompt -- if one works, the other should, too.

 

So my suggestion would be to open a Command prompt, type in a string like I typed (put your own Interface Name and the IP you want to use), and see if it works.  If it doesn't, I suppose it could be a "permissions" thing -- you might get an error message that sheds some light.

 

Bob Schor

0 Kudos
Message 6 of 6
(3,667 Views)