{"id":19321298,"url":"https://github.com/leshow/dhcpm","last_synced_at":"2025-04-09T23:17:28.466Z","repository":{"id":38229228,"uuid":"451243764","full_name":"leshow/dhcpm","owner":"leshow","description":"dhcpm is a CLI tool for constructing \u0026 sending DHCP messages","archived":false,"fork":false,"pushed_at":"2025-01-07T03:16:19.000Z","size":183,"stargazers_count":28,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-09T23:17:04.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leshow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-23T22:11:09.000Z","updated_at":"2025-02-18T20:16:42.000Z","dependencies_parsed_at":"2024-02-07T03:30:26.840Z","dependency_job_id":"42483c2e-7029-44ee-afdd-c5e340c84fc1","html_url":"https://github.com/leshow/dhcpm","commit_stats":{"total_commits":60,"total_committers":1,"mean_commits":60.0,"dds":0.0,"last_synced_commit":"e8c488c101cc9f78e10215753ed93bff8dc3c15e"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fdhcpm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fdhcpm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fdhcpm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leshow%2Fdhcpm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leshow","download_url":"https://codeload.github.com/leshow/dhcpm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125593,"owners_count":21051771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T01:36:40.677Z","updated_at":"2025-04-09T23:17:28.374Z","avatar_url":"https://github.com/leshow.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dhcpm\n\n## Sponsor\n\nThank you to [Bluecat](https://bluecatnetworks.com/) for sponsoring this work! `dhcpm` leverages [dhcproto](https://github.com/bluecatengineering/dhcproto) check that out for the DHCP protocol.\n\n## About\n\nA cli tool (and dhcp script runner!) for constructing \u0026 sending mocked dhcp client messages. `dhcpm` won't actually mess with the IP assigned to your network interfaces, it is intended to mock dhcp messages for testing dhcp servers. It aims to support v4 \u0026 v6, though v6 support is unfinished. Allows sending dhcp messages to non-default ports, and can be scripted with [rhai](https://github.com/rhaiscript/rhai).\n\nThis software is a personal project and should be considered beta. I use the basic cli features often, but the scripting features are new.\n\n## Installation\n\nYou can install with (use `--locked` because `argh` has been broken in a recent version)\n\n```\ncargo install dhcpm --locked\n```\n\nTo include the rhai scripting feature, add\n\n```\ncargo install dhcpm --features \"script\" --locked\n```\n\n## Use\n\n```\n\u003e dhcpm --help\n\nUsage: dhcpm \u003ctarget\u003e [-b \u003cbind\u003e] [-i \u003cinterface\u003e] [-p \u003cport\u003e] [-t \u003ctimeout\u003e] [--output \u003coutput\u003e] [--no-retry \u003cno-retry\u003e] [\u003ccommand\u003e] [\u003cargs\u003e]\n\ndhcpm is a cli tool for sending dhcpv4/v6 messages\n\nex  dhcpv4:\n        dhcpm 255.255.255.255 discover              (broadcast discover to default dhcp port)\n        dhcpm 192.168.0.255 discover                (broadcast discover on interface bound to 192.168.0.x)\n        dhcpm 0.0.0.0 -p 9901 discover              (unicast discover to 0.0.0.0:9901)\n        dhcpm 192.168.0.1 dora                      (unicast DORA to 192.168.0.1)\n        dhcpm 192.168.0.1 dora -o 118,hex,C0A80001  (unicast DORA, incl opt 118:192.168.0.1)\n    bootp:\n        dhcpm 255.255.255.255 bootreq           (broadcast BOOTREQ)\n    dhcpv6:\n        dhcpm ::0 -p 9901 inforeq       (unicast inforeq to [::0]:9901)\n        dhcpm ff02::1:2 inforeq         (multicast inforeq to default port)\n\nPositional Arguments:\n  target            ip address to send to\n\nOptions:\n  -b, --bind        address to bind to [default: INADDR_ANY:0]\n  -i, --interface   interface to use (requires root or `cap_net_raw`) [default:\n                    None - selected by OS]\n  -p, --port        which port use. [default: 67 (v4) or 546 (v6)]\n  -t, --timeout     query timeout in seconds [default: 5]\n  --output          select the log output format (json|pretty|debug) [default:\n                    pretty]\n  --no-retry        setting to \"true\" will prevent re-sending if we don't get a\n                    response [default: false]\n  --help            display usage information\n\nCommands:\n  discover          Send a DISCOVER msg\n  request           Send a REQUEST msg\n  release           Send a RELEASE msg\n  inform            Send an INFORM msg\n  decline           Send a DECLINE msg\n  dora              Sends Discover then Request\n  bootreq           Send a DISCOVER msg\n  inforeq           Send a INFORMATION-REQUEST msg (dhcpv6)\n```\n\n### Sending DHCP over arbitrary ports\n\nThis will construct a discover message and unicast to `192.168.0.1:9901`:\n\n```\ndhcpm 192.168.0.1 -p 9901 discover\n```\n\n`dhpcm` will bind to `0.0.0.0:0` for replies, meaning the server must speak DHCP over arbitrary ports. To communicate over the standard ports, simply don't provide the `--port` option. `dhcpm` will then listen to the default port if you have suitable permissions.\n\n```\ndhcpm 192.168.0.1 discover\n```\n\nThis will unicast to `192.168.0.1:67` and attempt to listen on `0.0.0.0:68`. You can change which address:port `dhcpm` listens on with the `--bind` option.\n\n### Broadcast vs unicast\n\nTo send a broadcast message (with the broadcast flag set) use the network broadcast address `255.255.255.255`.\n\n```\ndhcpm 255.255.255.255 discover\n```\n\n### Using specific interface\n\nYou can pass the `--interface/-i` param to bind to a specific interface by name, for example `--interface enp6s0`. Using this, you will only receive/send responses over that device. Ex,\n\n```\ndhcpm 255.255.255.255 -i enp6s0 discover --chaddr random\n```\n\nYou can also use `ip addr` on linux to get the broadcast address of a particular interface:\n\n```\n2: enp6s0: \u003cBROADCAST,MULTICAST,UP,LOWER_UP\u003e mtu 1500 qdisc mq state UP group default qlen 1000\n    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff\n    inet 192.168.0.130/24 brd 192.168.0.255 scope global noprefixroute enp6s0\n```\n\nNote `brd 192.168.0.255`. You can pass this to `dhcpm` and the kernel should select that interface to broadcast on (`enp6s0` in this example)\n\n```\ndhcpm 192.168.0.255 discover\n```\n\n### Message parameters\n\nEach sub-command (`discover`/`request`/`release`, etc) has sub-options. For example, by default dhcpm will use the default interfaces mac, you can override this by sending the appropriate Options\n\n```\ndhcpm 255.255.255.255 discover --chaddr \"80:FA:5B:41:10:6B\"\n```\n\n### dhcpv6\n\nWith DHCPv6, many messages are sent on the multicast group `ff02::1:2` but responses are often unicast back on link-local addresses (starting with `fe80`). `dhcpm` won't be able to receive this data if you've got another dhcpv6 client listening on `[::0]:546`, the dhcpv6 client port. The other process is will likely read the datagram first.\n\nFor example, my box has:\n\n```\n\u003e sudo lsof -Pi UDP\n...\nNetworkMa     711            root   20u  IPv6 12173080      0t0  UDP leshowbox:546\n```\n\nListening on this `[::0]:546`, so that process would need to be killed before `dhcpm` could print a reply. Still, I have often found it enough to use `dhpcm` to generate a message, then look at the response in wireshark or tcpdump to inspect its validity.\n\nSpecify an interface with v6, it is necessary to join the multicast group.\n\n```\n\u003e sudo dhcpm ff02::1:2 -i enp6s0 inforeq\n```\n\n### Scripting\n\nScripting support with [rhai](https://github.com/rhaiscript/rhai). Compile `dhcpm` with the `script` feature and give it a path with `--script`:\n\n```\ndhcpm 255.255.255.255 --script test.rhai\n```\n\nIn the script, you can create new discover arguments with:\n\n```\nlet args = discover::args_default();\n```\n\nYou can send this message with `args.send()`.\n\nMessage types supported in script are:\n\n- `discover::args_default()`\n- `request::args_default()`\n- `release::args_default()`\n- `inform::args_default()`\n\nBe careful about what scripts you choose to run, especially if you use ports only accessible with `sudo`, as the scripts arbitrary code will be executed with whatever permissions you give it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshow%2Fdhcpm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleshow%2Fdhcpm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleshow%2Fdhcpm/lists"}