0

I am trying to write a short c# app to solve the following problem. I have two network cards each with an IP address. when I try to set the IP of the 2nd adapter, the new IP conflicts with the one for the 1st adapter and therefore the IP and subset mask of the 2nd adapter are cleared out.

To solve the problem, is there a way in C# (using windows ManagementObject) to clear out the IP of the 1st adapter before I set the IP for the 2nd adapter to avoid conflicting? Or any other better ways?

I found a way to set the IP via ManagementObject in the question How to Change Public IP Address in C#, but do not know how to extend the method there to reset.

dbc
  • 104,963
  • 20
  • 228
  • 340
Roy
  • 1
  • This is not related to programming in any way. – Laurenz Albe Oct 11 '18 at 19:16
  • What do you mean with "_reset an IP address_"? That does not make any sense to me. (It is as meaningless as asking "how do i reset my house address" or "how do i reset a telephone number"). Also, i agree with Laurenz here: You know already how to manipulate/change the IP address of an adapter, so the question is not about how to do it, but rather what new value you would like/need for the IP address of adapter 1. ...which is not a question about programming but rather a question about your network setup/environment... –  Oct 11 '18 at 20:11
  • I clarified that the question is asking for a programmatic c# solution to a problem, ideally by extending the method shown in a pre-existing question. See also [ask]. That being said, there seems to be some difficulty in understanding your question. So I'd recommend you also [edit] your question, show the code you have now, and indicate where it fails -- i.e. a [mcve] showing the problem. – dbc Oct 11 '18 at 21:46
  • DHCP, Static how was the IP address assigned? ipconfig /release is probably the easiest way unless it is static. – Sorceri Oct 11 '18 at 21:56

0 Answers0