CCSWE.nanoFramework.DhcpServer
1.1.92
dotnet add package CCSWE.nanoFramework.DhcpServer --version 1.1.92
NuGet\Install-Package CCSWE.nanoFramework.DhcpServer -Version 1.1.92
<PackageReference Include="CCSWE.nanoFramework.DhcpServer" Version="1.1.92" />
<PackageVersion Include="CCSWE.nanoFramework.DhcpServer" Version="1.1.92" />
<PackageReference Include="CCSWE.nanoFramework.DhcpServer" />
paket add CCSWE.nanoFramework.DhcpServer --version 1.1.92
#r "nuget: CCSWE.nanoFramework.DhcpServer, 1.1.92"
#:package CCSWE.nanoFramework.DhcpServer@1.1.92
#addin nuget:?package=CCSWE.nanoFramework.DhcpServer&version=1.1.92
#tool nuget:?package=CCSWE.nanoFramework.DhcpServer&version=1.1.92
CCSWE.nanoFramework.DhcpServer
A simple DHCP server for nanoFramework.
Overview
This started as an effort to resolve some of the issues I was having with Iot.Device.DhcpServer and ending up turning into a complete re-write. I'll take to the team about backporting some of the fixes or using this code directly.
Features
- Entire DHCP message set is supported per RFC 2131
- Lease time with renewal and rebinding options are supported
- Extensible option support with several data types supported out of the box
Usage
The simplest usage is to create a new DhcpServer specifying the IP address of the server.
var dhcpServer = new DhcpServer(new IPAddress(new byte[] { 192, 168, 4, 1 }));
dhcpServer.Start();
Configuration
The DhcpServer constructor also has a parameter for the subnet mask that should be used. Internally the address pool only supports a class C (255.255.255.0) network which provides 253 addresses.
var dhcpServer = new DhcpServer(new IPAddress(new byte[] { 192, 168, 4, 1 }), new IPAddress(new byte[] { 255, 255, 255, 0 }));
dhcpServer.Start();
The default LeaseTime is two hours but this can be adjusted as needed.
dhcpServer.LeaseTime = TimeSpan.FromMinutes(5);
DHCP options
Several DHCP options are exposed directly as properties:
CaptivePortalUrl: Gets or sets the captive portal URL.DnsServer: Gets or sets the DNS server.
Additional options (including custom options) can be added to the OptionCollection exposed in the Options property.
dhcpServer.Options.Add(...);
Options are defined using the IOption interface. Several strongly typed option implementations are provided:
IPAddressOption: Represents a DHCP option with a singleIPAddressvalue.StringOption: Represents a DHCP option with astringvalue.TimeSpanOption: Represents a DHCP option with aTimeSpanvalue.
If none of these types meet your needs you can implement the IOption interface or use the base Option class which handles common logic for you.
Fixes (notes for myself for back porting)
- Proper handling of unicast and broadcast requests and repsonses
- Address pool expiration no longer crashes
- Captive portal uses the correct option code
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NETnanoFramework | netnano1.0 is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.17.11)
- nanoFramework.Logging (>= 1.1.161)
- nanoFramework.Runtime.Events (>= 1.11.32)
- nanoFramework.System.Collections (>= 1.5.67)
- nanoFramework.System.IO.Streams (>= 1.1.96)
- nanoFramework.System.Net (>= 1.11.47)
- nanoFramework.System.Text (>= 1.3.42)
- nanoFramework.System.Threading (>= 1.1.52)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.92 | 101 | 3/2/2026 |
| 1.1.91 | 95 | 2/28/2026 |
| 1.1.90 | 89 | 2/27/2026 |
| 1.1.89 | 87 | 2/27/2026 |
| 1.1.88 | 93 | 2/23/2026 |
| 1.1.86 | 234 | 11/6/2025 |
| 1.1.84 | 168 | 10/3/2025 |
| 1.1.83 | 227 | 7/7/2025 |
| 1.1.82 | 377 | 6/9/2025 |
| 1.1.81 | 366 | 6/9/2025 |
| 1.1.79 | 208 | 4/29/2025 |
| 1.1.78 | 239 | 4/28/2025 |
| 1.1.77 | 249 | 4/24/2025 |
| 1.1.75 | 287 | 4/17/2025 |
| 1.1.74 | 265 | 4/2/2025 |
| 1.1.73 | 229 | 3/26/2025 |
| 1.1.72 | 247 | 3/19/2025 |
| 1.1.71 | 189 | 3/14/2025 |
| 1.1.69 | 256 | 3/11/2025 |
| 1.1.68 | 249 | 3/11/2025 |