Skip to main content

Crate dhcplease

Crate dhcplease 

Source
Expand description

§dhcplease

A DHCP server library implementing RFC 2131 (DHCP) and RFC 2132 (DHCP Options).

§Features

  • Full DHCP protocol: DISCOVER, OFFER, REQUEST, ACK, NAK, RELEASE, DECLINE, INFORM
  • BOOTP compatibility for legacy clients
  • Static MAC-to-IP bindings
  • Lease persistence across restarts
  • Relay agent support (Option 82)
  • Rate limiting per client
  • Async/await with Tokio

§Quick Start

use dhcplease::{Config, DhcpServer};

#[tokio::main]
async fn main() -> dhcplease::Result<()> {
    let config = Config::load_or_create("config.json").await?;
    let server = DhcpServer::new(config).await?;
    server.run().await
}

§Architecture

  • Config - Server configuration (IP pool, lease duration, DNS, etc.)
  • DhcpServer - Main server that listens on UDP port 67
  • Leases - Thread-safe lease manager with persistence
  • DhcpPacket - DHCP packet parsing and encoding
  • DhcpOption - DHCP option types per RFC 2132

Re-exports§

pub use config::Config;
pub use config::StaticBinding;
pub use config::normalize_mac;
pub use config::sanitize_domain_name;
pub use config::sanitize_hostname;
pub use error::Error;
pub use error::Result;
pub use lease::Lease;
pub use lease::Leases;
pub use options::DhcpOption;
pub use options::MessageType;
pub use packet::DhcpPacket;
pub use server::DHCP_CLIENT_PORT;
pub use server::DHCP_SERVER_PORT;
pub use server::DhcpServer;

Modules§

config
DHCP server configuration.
error
Error types for the DHCP server.
lease
DHCP lease management and persistence.
options
DHCP options as defined in RFC 2132.
packet
DHCP packet parsing and encoding per RFC 2131.
server
DHCP server implementation.