A lightweight DHCP server implementation in Rust that handles basic DHCP operations including IP address assignment and lease management.
- Basic DHCP server functionality (DISCOVER, OFFER, REQUEST, ACK)
- SQLite-based lease management
- Configurable network interface binding
- Support for basic DHCP options (subnet mask, router, lease time, etc.)
- IPv4 address pool management (192.168.1.100-200 range)
- Rust 1.x
- SQLite3
- Root/sudo privileges (required for binding to port 67)
Basic usage example:
use mini_dhcp::MiniDHCPConfiguration;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Initialize the DHCP server with network interface
let config = MiniDHCPConfiguration::new("eth0".to_string()).await?;
// Start the DHCP server
mini_dhcp::start(config).await?;
Ok(())
}
The DHCP server is configured to:
- Listen on port 67
- Assign IP addresses in the range 192.168.1.100-200
- Use 192.168.1.69 as the default gateway
- Set lease time to 1 hour (3600 seconds)
- Use 255.255.255.0 as subnet mask
The server uses SQLite to store lease information. The database file is automatically created as dhcp.db
in the current directory.
- DISCOVER
- OFFER
- REQUEST
- ACK
- DECLINE (logged only)
- RELEASE (logged only)
- INFORM (logged only)