What API can be used to send DHCP Discovery, Request, and Acknowledgement?
-
30-06-2021 - |
Question
I have been searching for quite a while and cannot seem to find a working DHCP Client implementation example in C#. I am brand spankin' new to Network Programming, but am doing some research that requires me to write a manual DHCP client and to implement Auto-IP if there is no DHCP server.
Any code examples, or names of built-in C# classes that can help me with this would be appreciated.
Solution
You are not going to find that; the reason is “security”.
Regular net APIs allow you to handle Level-3 and up but a DHCP client must be able to handle Level-2; i.e. for broadcasting to MAC FF:FF:FF:FF:FF:FF on DHCP DISCOVERY packets
For security reasons Microsoft today does not allow you to craft Ethernet packages at such a low level.
You cannot use raw sockets; read here why:
Limitations on Raw Sockets
http://msdn.microsoft.com/en-us/library/ms740548(v=vs.85).aspx
OTHER TIPS
You can install the pccap driver on your pc and use that apI to send raw packets