set IPaddress, Gateway, Subnet, DNS using Network Interface class

Kran2022 406 Reputation points
2022-12-06T09:53:49.857+00:00

Hi All: Morning.

Is there any way to change Network adapter properties from DHCP to static like IP address, Subnet, gateway & DNS using Network Interface class.

From the link, i dont see any example; there is a plenty of example to get/read ipaddress, gateway etc...but not for set ip address or i may i'm missed to read/look properly.

Could you please provide me an exeple to set static IP using NetworkInterface class? i know we can set static IP using Win32, Management Object or using Netsh. Thnaks

Developer technologies | Windows Presentation Foundation
Developer technologies | XAML
Developer technologies | C#
0 comments No comments
{count} votes

Accepted answer
  1. Hui Liu-MSFT 48,676 Reputation points Microsoft External Staff
    2022-12-07T07:33:06.97+00:00

    Hi,@Kran2022 . Welcome Microsoft Q&A.

    As you said, the documentation shows that the NetworkInterface class does not have some set methods. It doesn't seem to be able to set the IP through NetworkInterface.

    ----------------------------------------------------------------------------

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.