{"id":30950996,"url":"https://github.com/imgurbot12/pydhcp","last_synced_at":"2025-10-23T20:41:14.202Z","repository":{"id":154089416,"uuid":"631737526","full_name":"imgurbot12/pydhcp","owner":"imgurbot12","description":"Simple Python DHCP Library. DHCP Packet-Parsing/Client/Server","archived":false,"fork":false,"pushed_at":"2025-02-18T18:24:47.000Z","size":93,"stargazers_count":24,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-18T01:44:53.298Z","etag":null,"topics":["dhcp","dhcp-client","dhcp-server","dhcpv4","python","python3"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pydhcp3/","language":"Python","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/imgurbot12.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":"2023-04-24T00:08:23.000Z","updated_at":"2025-08-16T21:59:02.000Z","dependencies_parsed_at":"2025-01-15T09:04:23.633Z","dependency_job_id":null,"html_url":"https://github.com/imgurbot12/pydhcp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imgurbot12/pydhcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgurbot12%2Fpydhcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgurbot12%2Fpydhcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgurbot12%2Fpydhcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgurbot12%2Fpydhcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imgurbot12","download_url":"https://codeload.github.com/imgurbot12/pydhcp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgurbot12%2Fpydhcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274582649,"owners_count":25311653,"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","status":"online","status_checked_at":"2025-09-11T02:00:13.660Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dhcp","dhcp-client","dhcp-server","dhcpv4","python","python3"],"created_at":"2025-09-11T05:27:30.422Z","updated_at":"2025-10-23T20:41:09.162Z","avatar_url":"https://github.com/imgurbot12.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pydhcp\n-------\n\n[![PyPI version](https://img.shields.io/pypi/v/pydhcp3?style=for-the-badge)](https://pypi.org/project/pydhcp3/)\n[![Python versions](https://img.shields.io/pypi/pyversions/pydhcp3?style=for-the-badge)](https://pypi.org/project/pydhcp3/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://github.com/imgurbot12/pydhcp/blob/master/LICENSE)\n[![Made with Love](https://img.shields.io/badge/built%20with-%E2%99%A5-orange?style=for-the-badge)](https://github.com/imgurbot12/pydhcp)\n\nSimple Python DHCP Library. DHCP Packet-Parsing/Client/Server\n\n### Installation\n\n```\npip install pydhcp3\n```\n\n### DHCPv4 Examples\n\nPacket Parsing\n\n```python\nfrom pydhcp.v4 import Message\n\nhex = \\\n    '0101060000003d1d0000000000000000000000000000000000000000000b8201fc4200' +\\\n    '0000000000000000000000000000000000000000000000000000000000000000000000' +\\\n    '0000000000000000000000000000000000000000000000000000000000000000000000' +\\\n    '0000000000000000000000000000000000000000000000000000000000000000000000' +\\\n    '0000000000000000000000000000000000000000000000000000000000000000000000' +\\\n    '0000000000000000000000000000000000000000000000000000000000000000000000' +\\\n    '0000000000000000000000000000000000000000000000000000638253633501013d07' +\\\n    '01000b8201fc4232040000000037040103062aff00000000000000'\n\nraw     = bytes.fromhex(hex)\nmessage = Message.unpack(raw)\nprint(message)\n```\n\nClient\n\n```python\nfrom pydhcp.v4 import Message\nfrom pydhcp.v4.client import Client, new_message_id\n\nmac    = 'aa:bb:cc:dd:ee:ff'\nclient = Client(interface=None)\n\n# send crafted messages\nid       = new_message_id()\nhwaddr   = bytes.fromhex(mac.replace(':', ''))\nrequest  = Message.discover(id, hwaddr)\nresponse = client.request(request)\nprint(response)\n\n# or simplify the standard network assignment request process\nrecord = client.request_assignment(mac)\nprint(record)\n```\n\nServer\n\n```python\nimport logging\nfrom ipaddress import IPv4Address, IPv4Network\n\nfrom pyserve import listen_udp_threaded\n\nfrom pydhcp.v4.server import Server\nfrom pydhcp.v4.server.backend import MemoryBackend, CacheBackend\n\n# prepare simple memory backend as base provider\nbackend = MemoryBackend(\n    network=IPv4Network('192.168.1.0/24'),\n    gateway=IPv4Address('192.168.1.1'),\n    dns=[IPv4Address('8.8.8.8'), IPv4Address('8.8.4.4')],\n)\n\n# wrap backend w/ cache (not really useful here but for non-memory backends)\nbackend = CacheBackend(backend)\n\n# configure optional logger for server implementaion\nlogging.basicConfig(level=logging.DEBUG)\nlogger = logging.getLogger('myserver')\nlogger.setLevel(logging.INFO)\n\n# launch server and run forever using pyserve\nlisten_udp_threaded(\n    address=('0.0.0.0', 67),\n    factory=Server,\n    allow_broadcast=True,\n    backend=backend,\n    logger=logger,\n    server_id=IPv4Address('192.168.1.1') # dhcp server address\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimgurbot12%2Fpydhcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimgurbot12%2Fpydhcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimgurbot12%2Fpydhcp/lists"}