| Crates.io | mydhcp |
| lib.rs | mydhcp |
| version | 0.1.0 |
| created_at | 2025-07-18 11:23:00.134622+00 |
| updated_at | 2025-07-18 11:23:00.134622+00 |
| description | A minimal DHCP client implemented in Rust. |
| homepage | https://github.com/XFajk/mydhcp |
| repository | https://github.com/XFajk/mydhcp |
| max_upload_size | |
| id | 1758870 |
| size | 101,296 |
A basic DHCP client written in Rust.
mydhcp is a standalone DHCP client made build out of curiosity of how DHCP and low level networking works it only supports linux because it used AF_PACKET socket's for total control over what gets set.
mydhcp is intentionally minimal and only supports IPv4 DHCP on Linux. Current capabilities include:
DHCPDISCOVER → DHCPOFFER → DHCPREQUEST → DHCPACKDHCPRELEASE on SIGINT or panic (cleanup logic included)ip route add default)/etc/resolv.conf)The project tries to use Rust safely, but it does contain some unsafe code due to use of libc. Notably:
ManualDrop is used in the keep_track method to manage lease state cleanupkeep_trackIf you're concerned about security, treat this as an educational reference, not production code.
This project is primarily for learning and exploration. It's not production-ready and may contain memory safety bugs or rough edges.
You may find it useful as:
A starting point for writing your own DHCP client
A reference for low-level networking in Rust
A personal experiment to study packet formats and system integration
For now you can only build from source with cargo.
git clone https://github.com/XFajk/mydhcp.git
cd mydhcp
cargo build --release
Before running, note:
You can use the setup_for_testing.sh script to configure your environment safely. Review what it does before running:
SET_FOR_TESTING=1 ./test-net.sh [SSID] [PASSWORD] [INTERFACE]
sudo RUST_LOG=info ./target/release/mydhcp [INTERFACE]
To clean up:
SET_FOR_TESTING=0 ./setup_for_testing.sh
You can view code-level documentation using:
cargo doc --open