![]() |
VOOZH | about |
dotnet add package nanoFramework.Iot.Device.DhcpServer --version 1.2.951
NuGet\Install-Package nanoFramework.Iot.Device.DhcpServer -Version 1.2.951
<PackageReference Include="nanoFramework.Iot.Device.DhcpServer" Version="1.2.951" />
<PackageVersion Include="nanoFramework.Iot.Device.DhcpServer" Version="1.2.951" />Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.DhcpServer" />Project file
paket add nanoFramework.Iot.Device.DhcpServer --version 1.2.951
#r "nuget: nanoFramework.Iot.Device.DhcpServer, 1.2.951"
#:package nanoFramework.Iot.Device.DhcpServer@1.2.951
#addin nuget:?package=nanoFramework.Iot.Device.DhcpServer&version=1.2.951Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.DhcpServer&version=1.2.951Install as a Cake Tool
This binding offers simple and efficient DHCP capabilities. It is following the RFC2131 and does implement the minimum set to offer decent DHCP capabilities.
You simply create a server, set the DHCP address and the mask.
DhcpServer dhcpserver = new DhcpServer();
// Give the captive portal URL. Note: this is experimental and as RFC is new, only works on a limited number of devices.
dhcpserver.CaptivePortalUrl = "http://192.168.4.1";
// Starts the server with the DHCP server address (should be the device address) and the mask.
dhcpserver.Start(IPAddress.Parse(new IPAddress(new byte[] {192, 168, 4, 1}), new IPAddress(new byte[] { 255, 255, 255, 0 })));
By default the time to leave is set to 1200 seconds, you adjust it.
Optionally you can set the DNS and Gateway IP addresses using the respective properties. Like this:
// DNS server
dhcpserver.DnsServer = IPAddress.Parse("192.168.4.1");
// Gateway (router)
dhcpserver.Gateway = IPAddress.Parse("192.168.4.1");
Also note that the server will smartly manage the IP addresses and will give the preference to any device if it's available or if the device had it before. It will also clean the bails to make sure there is always enough space available.
While you can use this simple and efficient server in a real network, it remains for simple usage and is not recommended in production.
The sample is a complete example on how to use this DHCP server to provide IP addresses to a phone or a PC you'll connect to the .NET nanoFramework device to setup the Wireless configuration it has to connect to.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET Framework | net net is compatible. |
Showing the top 4 NuGet packages that depend on nanoFramework.Iot.Device.DhcpServer:
| Package | Downloads |
|---|---|
|
MakoIoT.Device.Services.ConfigurationManager
Configuration mode manager for MAKO-IoT |
|
|
MakoIoT.Device.Services.ConfigurationApi
REST API for configuration with MAKO-IoT |
|
|
MakoIoT.Device.Services.WiFi.AP
WiFi Access Point library for MAKO-IoT |
|
|
MakoIoT.Device.Platform.LocalConfig
MAKO-IoT Platform local configuration library. On-device web server, WiFi AP |
Showing the top 1 popular GitHub repositories that depend on nanoFramework.Iot.Device.DhcpServer:
| Repository | Stars |
|---|---|
|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0-preview.85 | 50 | 6/1/2026 |
| 2.0.0-preview.80 | 50 | 5/27/2026 |
| 2.0.0-preview.73 | 56 | 5/20/2026 |
| 2.0.0-preview.69 | 51 | 5/18/2026 |
| 2.0.0-preview.62 | 55 | 5/13/2026 |
| 2.0.0-preview.49 | 57 | 5/4/2026 |
| 2.0.0-preview.45 | 62 | 4/29/2026 |
| 2.0.0-preview.32 | 58 | 4/20/2026 |
| 2.0.0-preview.16 | 79 | 3/10/2026 |
| 1.2.951 | 136 | 6/1/2026 |
| 1.2.949 | 209 | 5/18/2026 |
| 1.2.938 | 319 | 4/9/2026 |
| 1.2.909 | 923 | 11/24/2025 |
| 1.2.907 | 436 | 11/17/2025 |
| 1.2.902 | 337 | 11/10/2025 |
| 1.2.891 | 322 | 10/28/2025 |
| 1.2.886 | 274 | 10/10/2025 |
| 1.2.878 | 354 | 10/2/2025 |
| 1.2.851 | 2,619 | 4/24/2025 |
| 1.2.835 | 1,601 | 4/2/2025 |