Solved

Programmatically change IP address in 9x/NT with no reboot

Posted on 2001-07-10
11
258 Views
Last Modified: 2012-06-27
Hi

I would like to alter the IP address of a network card using Visual C++ without having to do a reboot.

I have found some settings in registry but these seem to require a reboot for them to take effect.

I have also found IP helper commands to do the above, but this only works for windows 2000 and onwards. This needs to work on 95/98/ME/NT4/NT2000.

Can anyone help?
0
Comment
Question by:fel080497
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 6268685
This cannot be done without a reboot.  Windows 9x has no facility to accomplish this either via an API or via undocumented "tricks".

It is possible to accomplish this for NT4 using an undocumented API call to DchpNotifyConfigChange() in the DHCP DLL but this doesn't exist on Win9x.
0
 
LVL 1

Expert Comment

by:ccaprar
ID: 6268733
I also know that this cannot be done in Win9x without a reboot. The same is true for DNS changes or other things like that. Changing IP without rebooting only exists in Win2K :)
0
 
LVL 32

Expert Comment

by:jhance
ID: 6269215
>>The same is true for DNS changes...

No, the same is NOT true for DNS.  The DNS address can be changed at any time and the new value will be immediately used.
0
 
LVL 3

Expert Comment

by:MDarling
ID: 6269708
We use WinIPCFG to hot swap between 2 networks on Win98.

One network is on 192.168.0.xxx
the other is on 192.168.1.xxx

Both networks have a DHCP server

Using WinIPCFG we can unplug the cable from the network card and plug in a cable connected to the other network.

We then do release and renew with WinIPCFG and it gets a new IP address from the DHCP server on the network.

This is cleary changing IP addresses without a reboot.

Regards,
Mike.
0
 
LVL 32

Expert Comment

by:jhance
ID: 6269880
>>This is cleary changing IP addresses without a reboot.

Not really.  I believe this question is about changing STATIC IP addresses which is not the same as renewing DHCP addresses.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:fel080497
ID: 6271403
Yes, I to have used WinIPcfg and ipconfig to renew DHCP addresses. But what I need is to be able to change static IP addresses.

So just what is the difference between DHCP changing the IP address and changing a static IP address. SUrely if DHCP can do it, then so can we!

Perhaps I dont understand the difference between the two?
0
 
LVL 32

Expert Comment

by:jhance
ID: 6271470
For whatever reason, the way Microsoft designed the TCPIP stack in Win95, 98, and ME, it CANNOT change from one static IP to another, from DHCP to static, or from static to DHCP without a reboot.  It simply cannot be done.

There is no technical reason why it could not be designed to be possible as NT4 and Win2000 prove.

DHCP is handled differently in the driver and needs to reboot.
0
 
LVL 3

Expert Comment

by:MDarling
ID: 6272586
>>So just what is the difference between DHCP changing the
>>IP address and changing a static IP address.
>> SUrely if DHCP can do it, then so can we!

I guess DHCP is built around the idea of renewal and that it would need to support the possibility that an IP address could change.

Maybe MS just got lazy in this case and found that the static and dynamic portions of the 9x stacks were incompatible?  (maybe written by different teams?)

Maybe their is a very good 9x reason for it - who knows?

0
 

Author Comment

by:fel080497
ID: 6274704
Hmmm, thank you microsoft is all I can say!!

This may sound a bit wacky, but do you know if a mini DHCP server could be written to run on the machines that is having the IP address changed. So that when they request a new IP address this responds with the new IP address which is then assigned using DHCP? Then in theory you could swap between two fixed addresses.

Can you run a DHCP server on the same machine that is requesting a new IP address? and is there a way of making the machine goto its own specific DHCP server?

Otherwise it looks like an upgrade to win2000 will have to be done in order to have this funcionality. (Nice one microsoft)
0
 
LVL 32

Accepted Solution

by:
jhance earned 200 total points
ID: 6274799
fel,

In answer to your question, yes that certainly could be done.  I think the best approach is to implement an NDIS Intermediate driver (which goes between the top of the NDIS network card driver and below the transport drivers like TCPIP) and has access to all of the network traffic on the machine.  In essence a packet filter.  It would watch for a DHCP request, answer it itself, and could then configure whatever it wanted to configure on the local machine.

It's certainly not an impossible job but it's enough work that you're going to need a good reason for doing it.
0
 

Author Comment

by:fel080497
ID: 6276283
Oh well thanks for answering, it may not have been the answer I was looking for but at least it confirmed my suspicions.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now