| Crates.io | crdhcpc |
| lib.rs | crdhcpc |
| version | 0.1.1 |
| created_at | 2025-12-14 19:25:33.762562+00 |
| updated_at | 2025-12-14 19:25:33.762562+00 |
| description | Standalone DHCP Client for Linux with DHCPv4, DHCPv6, PXE, and Dynamic DNS support |
| homepage | https://github.com/greenpdx/crdhcpd |
| repository | https://github.com/greenpdx/crdhcpd |
| max_upload_size | |
| id | 1984981 |
| size | 593,405 |
A comprehensive, secure DHCP client written in Rust, supporting DHCPv4, DHCPv6, PXE boot, Dynamic DNS, and more.
# Build
cd crdhcpc
cargo build --release
# Start on an interface
crdhcpc -c /etc/dhcp-client.toml start eth0
# Run as daemon
crdhcpc -c /etc/dhcp-client.toml daemon
# Check status
crdhcpc status eth0
┌─────────────────────────────────────────────────┐
│ REST API (Axum) │
│ GET /api/dhcp-client/status │
│ POST /api/dhcp-client/start │
│ POST /api/dhcp-client/renew │
└─────────────────┬───────────────────────────────┘
│
┌─────────────────▼───────────────────────────────┐
│ JSON-RPC Plugin (crrouterd) │
│ dhcpclient.status │
│ dhcpclient.start │
│ dhcpclient.renew │
└─────────────────┬───────────────────────────────┘
│
┌─────────────────▼───────────────────────────────┐
│ DHCP Client Manager │
│ ┌──────────────┬───────────────┐ │
│ │ DHCPv4 │ DHCPv6 │ │
│ │ - DORA │ - SARR │ │
│ │ - BOOTP │ - Prefix Del. │ │
│ └──────────────┴───────────────┘ │
│ ┌──────────────┬───────────────┐ │
│ │ PXE │ DDNS │ │
│ │ TFTP │ Failover │ │
│ └──────────────┴───────────────┘ │
└─────────────────┬───────────────────────────────┘
│
┌─────────────────▼───────────────────────────────┐
│ Network Integration │
│ NetworkManager │ Unbound │ lnxnetctl │
└─────────────────────────────────────────────────┘
cargo install --path .
When building as part of crrouter-web:
cargo build --features dhcp-client
For systemd-based systems:
# Daemon mode (recommended) - manages all interfaces
sudo cp systemd/dhcp-client-standalone.service /etc/systemd/system/
sudo systemctl enable dhcp-client-standalone.service
sudo systemctl start dhcp-client-standalone.service
# Per-interface mode
sudo cp systemd/dhcp-client@.service /etc/systemd/system/
sudo systemctl enable dhcp-client@eth0.service
sudo systemctl start dhcp-client@eth0.service
See systemd/README.md for complete systemd integration details.
Example configuration file (/etc/dhcp-client.toml):
[general]
enabled = true
interfaces = ["eth0"]
[dhcpv4]
enabled = true
hostname = "router"
send_hostname = true
timeout = 30
retry_count = 3
[dhcpv6]
enabled = false
prefix_delegation = true
rapid_commit = true
[security]
validate_server = true
allowed_servers = ["192.168.1.1"]
min_lease_time = 300
max_lease_time = 604800
[ddns]
enabled = false
update_forward = true
update_reverse = true
See docs/QUICK_REFERENCE.md for complete configuration reference.
# Start DHCP client on an interface
crdhcpc -c /etc/dhcp-client.toml start eth0
# Run as a daemon (manages all configured interfaces)
crdhcpc -c /etc/dhcp-client.toml daemon
# Check status
crdhcpc status # All interfaces
crdhcpc status eth0 # Specific interface
# Renew lease
crdhcpc renew eth0
# Release lease
crdhcpc release eth0
# Stop client
crdhcpc stop eth0
The daemon provides a JSON-RPC 2.0 interface on /var/run/crdhcpc.sock:
# Get status
curl -X POST http://localhost:8080/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "dhcpclient.status",
"params": {},
"id": 1
}'
# Start client on interface
curl -X POST http://localhost:8080/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "dhcpclient.start",
"params": {"interface": "eth0"},
"id": 1
}'
# Renew lease
curl -X POST http://localhost:8080/rpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "dhcpclient.renew",
"params": {"interface": "eth0"},
"id": 1
}'
When running as part of crrouter-web:
# The plugin is automatically loaded when crrouterd starts
sudo systemctl start crrouterd
# Status is available via REST API
curl http://localhost:8080/api/dhcp-client/status
# Control via REST API
curl -X POST http://localhost:8080/api/dhcp-client/start \
-H "Content-Type: application/json" \
-d '{"interface": "eth0"}'
Always configure allowed servers in production:
[security]
allowed_servers = ["192.168.1.1", "192.168.1.2"]
validate_server = true
Set reasonable lease time bounds:
[security]
min_lease_time = 300 # 5 minutes
max_lease_time = 604800 # 7 days
Prevent DHCP exhaustion attacks:
[security]
max_request_rate = 10 # requests per second per interface
Use TSIG for secure DNS updates:
[ddns]
tsig_key_name = "dhcp-update-key"
tsig_key = "base64-encoded-key"
All DHCP events are logged:
RUST_LOG=debug crdhcpc daemon
MOCK_DHCP_CLIENT=true crdhcpc daemon
MIT OR Apache-2.0