100% AI
Find a file
2025-12-20 17:37:48 -07:00
src AI 2025-12-20 17:37:32 -07:00
Cargo.lock I vibe with this 2025-12-20 16:43:09 -07:00
Cargo.toml AI 2025-12-20 17:37:32 -07:00
dhcp_config.toml AI 2025-12-20 17:37:32 -07:00
README.md AI 2025-12-20 17:37:32 -07:00

RDHCP Server

A simple, Rust-based DHCP server for Windows with both Terminal User Interface (TUI) and Graphical User Interface (GUI) modes.

Features

  • Dual Interface Modes: Choose between TUI (terminal) or GUI (graphical) mode
  • Network Interface Selection: Select which network interface to run the DHCP server on
  • Live Lease Monitoring: View assigned IP addresses alongside MAC addresses
  • Client Activity Indicator: See which clients are currently active
  • Configurable IP Pool: Define your own IP address range, subnet mask, gateway, and DNS servers
  • Static IP Reservations: Reserve specific IPs for specific MAC addresses
  • Simple Configuration: TOML-based configuration file

Requirements

  • Windows 10/11
  • Administrator privileges (required to bind to DHCP ports 67/68)
  • Rust toolchain (for building from source)

Installation

Building from Source

# Clone the repository
git clone <repository-url>
cd rdhcp_server

# Build in release mode
cargo build --release

# The executable will be at target/release/rdhcp_server.exe

Usage

Command Line Options

rdhcp_server [OPTIONS]

Options:
  -m, --mode <MODE>      UI mode to use [default: tui] [possible values: tui, gui]
  -c, --config <CONFIG>  Path to configuration file [default: dhcp_config.toml]
      --generate-config  Generate a default configuration file
  -h, --help             Print help
  -V, --version          Print version

Examples

# Run in TUI mode (default)
rdhcp_server.exe

# Run in GUI mode
rdhcp_server.exe --mode gui

# Use a custom configuration file
rdhcp_server.exe --config my_config.toml

# Generate a default configuration file
rdhcp_server.exe --generate-config

TUI Mode

The TUI mode provides a terminal-based interface with the following screens:

  1. Interface Selection: Select the network interface to bind the DHCP server to
  2. Dashboard: Monitor leases, view logs, and control the server

TUI Keyboard Shortcuts

Interface Selection Screen:

  • / or j/k: Navigate interfaces
  • Enter: Select interface
  • r: Refresh interface list
  • q: Quit

Dashboard Screen:

  • Tab: Switch between Leases and Log panels
  • / or j/k: Navigate items
  • d: Revoke selected lease
  • s: Start/Stop server
  • Esc: Return to interface selection
  • q: Quit

GUI Mode

The GUI mode provides a graphical interface with:

  • Left panel: Interface selection and server controls
  • Central panel: Lease table and activity log
  • Settings window: Configure DHCP pool settings

Configuration

The server uses a TOML configuration file. Generate a default one with:

rdhcp_server.exe --generate-config

Configuration Options

# Network interface to bind to (optional - can be selected at runtime)
# interface = "Ethernet"

# IP Address Pool
pool_start = "192.168.1.100"
pool_end = "192.168.1.200"
subnet_mask = "255.255.255.0"
gateway = "192.168.1.1"
dns_servers = ["8.8.8.8", "8.8.4.4"]

# Lease duration in seconds (default: 1 hour)
lease_duration_secs = 3600

# Optional settings
# domain_name = "local"
# broadcast_address = "192.168.1.255"

# Server ports (standard DHCP ports)
server_port = 67
client_port = 68

# Static IP Reservations
[[reservations]]
mac = "00:11:22:33:44:55"
ip = "192.168.1.150"
hostname = "my-server"

Lease Information Display

The server displays the following information for each lease:

Field Description
Status Active (●) or Inactive/Expired (○)
MAC Address Client's hardware address
IP Address Assigned IP address
Hostname Client hostname (if provided)
Expires In Time remaining on the lease

A client is considered active if:

  • The lease has not expired
  • Activity was detected within the last 60 seconds

Important Notes

  1. Administrator Privileges: The DHCP server requires administrator privileges to bind to ports 67 and 68. Run the application as Administrator.

  2. Network Conflicts: Ensure no other DHCP server is running on the same network segment to avoid IP conflicts.

  3. Firewall: You may need to allow the application through Windows Firewall for it to receive DHCP requests.

  4. IP Pool Range: Make sure your IP pool doesn't conflict with:

    • The gateway address
    • Other static devices on the network
    • The server's own IP address

Project Structure

rdhcp_server/
├── Cargo.toml           # Project dependencies
├── dhcp_config.toml     # Default configuration file
├── README.md            # This file
└── src/
    ├── main.rs          # Entry point and CLI handling
    ├── config.rs        # Configuration parsing and validation
    ├── dhcp.rs          # DHCP protocol implementation
    ├── network.rs       # Network interface discovery (Windows)
    ├── lease.rs         # Lease management
    ├── state.rs         # Shared application state
    ├── tui_mode.rs      # Terminal UI implementation
    └── gui_mode.rs      # Graphical UI implementation

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit issues and pull requests.