nanoFramework.Iot.Device.DhcpServer 1.2.886

Prefix Reserved
dotnet add package nanoFramework.Iot.Device.DhcpServer --version 1.2.886
                    
NuGet\Install-Package nanoFramework.Iot.Device.DhcpServer -Version 1.2.886
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="nanoFramework.Iot.Device.DhcpServer" Version="1.2.886" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="nanoFramework.Iot.Device.DhcpServer" Version="1.2.886" />
                    
Directory.Packages.props
<PackageReference Include="nanoFramework.Iot.Device.DhcpServer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add nanoFramework.Iot.Device.DhcpServer --version 1.2.886
                    
#r "nuget: nanoFramework.Iot.Device.DhcpServer, 1.2.886"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package nanoFramework.Iot.Device.DhcpServer@1.2.886
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=nanoFramework.Iot.Device.DhcpServer&version=1.2.886
                    
Install as a Cake Addin
#tool nuget:?package=nanoFramework.Iot.Device.DhcpServer&version=1.2.886
                    
Install as a Cake Tool

DHCP Server

This binding offers simple and efficient DHCP capabilities. It is following the RFC2131 and does implement the minimum set to offer decent DHCP capabilities.

Reference

Usage

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.

Information on the sample

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.

Limitations

  • This server does only support the basic flow. It does not support advanced flow with Renew and Release.
  • While you can specify the mask you want, internally, the server only support mask C. So it will allocate 253 addresses maximum.
  • While the Captive Portal option is supported from the latest RFC8910, only few OS and mobile phones supports it today. It is still experimental.
Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

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.WiFi.AP

WiFi Access Point library for MAKO-IoT

MakoIoT.Device.Services.ConfigurationApi

REST API for configuration with MAKO-IoT

MakoIoT.Device.Platform.LocalConfig

MAKO-IoT Platform local configuration library. On-device web server, WiFi AP

GitHub repositories (1)

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
1.2.886 46 10/10/2025
1.2.878 242 10/2/2025
1.2.851 2,513 4/24/2025
1.2.835 1,487 4/2/2025
1.2.823 1,537 3/11/2025
1.2.809 663 3/3/2025
1.2.804 783 2/27/2025
1.2.800 188 2/27/2025
1.2.793 360 2/26/2025
1.2.761 1,285 2/5/2025
1.2.743 192 2/4/2025
1.2.726 217 1/31/2025
1.2.718 204 1/29/2025
1.2.708 246 1/13/2025
1.2.700 194 1/8/2025
1.2.667 350 12/16/2024
1.2.644 2,610 10/23/2024
1.2.602 3,259 8/28/2024
1.2.574 1,450 7/31/2024
1.2.541 964 6/14/2024
1.2.519 2,444 5/15/2024
1.2.507 1,453 4/15/2024
1.2.454 3,032 1/31/2024
1.2.450 952 1/27/2024
1.2.443 1,100 1/19/2024
1.2.407 6,622 11/10/2023
1.2.378 1,737 10/11/2023
1.2.300 3,313 5/26/2023
1.2.284 992 5/12/2023
1.2.268 286 5/3/2023
1.2.174 1,207 12/28/2022
1.2.124 578 11/5/2022
1.2.112 526 10/25/2022
1.2.89 607 10/11/2022
1.2.85 509 10/8/2022
1.2.66 538 9/22/2022
1.2.60 570 9/16/2022
1.2.6 570 8/4/2022
1.2.1 519 8/2/2022