2

Is there any Class/Namespace I can use to query DHCP server and get the list of all theReserved IPs?

Asdfg
  • 11,362
  • 24
  • 98
  • 175
  • Please have a look at the answers here: http://stackoverflow.com/questions/2224877/querying-a-dhcp-server-in-c-sharp – Joakim Hansson Sep 12 '15 at 01:10
  • @zatixiz : I did not ask the question without searching google – Asdfg Sep 12 '15 at 01:15
  • Either that, or make a powershell module to use the cmdlets https://technet.microsoft.com/en-us/library/jj590751(v=wps.630).aspx – Joakim Hansson Sep 12 '15 at 01:20
  • One of my current positions is network administrator, and DHCP is something I've never considered handling/querying in C# so it's quite interesting to me as well. I will have a closer look at it and let you know if I come up with something! – Joakim Hansson Sep 12 '15 at 01:31
  • Does the DHCP protocol allow you to query for all the reserved addresses? I thought you could only ask to lease and release an IP address. – Lasse V. Karlsen Sep 13 '15 at 20:07
  • @LasseV.Karlsen: PowerShell cmdlets for DHCP (Windows 2012) allows to do that if you have proper rights – Asdfg Sep 14 '15 at 03:18

1 Answers1

1

As per my knowledge and bit of search online, I guess there isn't any .NET namespace which you can use to achieve what you want. But then for that you can use Win32 Native API. Please refer this link. And to get some idea of the use of this API, you can find some code samples here.

You can find more useful information on this from the following web links:

  1. Querying Windows DHCP Server With C#
  2. IPInterfaceProperties.DhcpServerAddresses Property

Hope this answer helps and adds somethings valuable to your quest !

Edit: This solution which I mentioned is Win32 APIs which is basically unmanaged code. I just noticed your question heading has (Managed Code). And this solution probably might not be new to you. Still I am keeping it here as an answer to other solution seekers. And to Call Native Functions from Managed Code.

Benison Sam
  • 2,755
  • 7
  • 30
  • 40