Jump to content

Programmatically changing a host computer's IP?


Recommended Posts

Has anybody programmatically changed a computer's IP Address using LabVIEW?

I'm in a situation where I will have a LabVIEW App running on a computer having a few ethernet adapters.

What I would like to do is somehow identify the adapters and programmatically set the ip addresses and subnet masks of each adapter and apply the settings without having to reboot. Sort of like how you can change the IP and implement the changes manually by viewing local area connection properties.

Extra tidbit of info: we're going to be using W2k/XP machines.

I'm thinking it's probably going to be a register-level implementation, which we would like to try to avoid. If anybody is able to at least point me in the general direction, I would greatly appreciate it.

Link to comment

What a great question Bryan! :D

Unfortunately I don't know the answer - although I recently heard of a program written by someone at UVA which uses Microsoft Visio to dynamically configure network IP addresses. Here is a link to their site: http://www.cs.virginia.edu/~mngroup/projects/routeconfig/

Actually, I just took another look and this software does routing - which doesn't ussually involve configuring local IP addresses. So maybe it isn't much help after all.

Link to comment

OK, since I have an interest in solving this problem as well I did a little research last night and this is what I found:

Method One, NETSH:

use the "System Exec" function to use "netsh" as follows:

netsh interface ip set address <interface name> static <ip address> <mask> <default gateway> <gateway interface metric>

Examples:

netsh interface ip set address "Local Area Connection 2" static 192.168.1.10 255.255.255.0 192.168.1.1 1netsh interface ip set address "Local Area Connection 5" static 10.12.1.95 255.255.255.0

Method Two, Edit Registry:

Use the LabVIEW registry editing functions to query and edit the following registry settings:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards

(query this to find ID numbers for all network cards)

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\

In this key will be a sub key for every network card. By makeing sure DHCP is disabled (value 0) and setting the IP Address for each card, you should be able to do what you want.

This Registry editing method probably requires you to reboot.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.