mirror of
https://github.com/netbootxyz/docker-netbootxyz.git
synced 2026-04-24 22:45:49 +03:00
[PR #73] Add proxy-DHCP support #208
Labels
No labels
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/docker-netbootxyz#208
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/netbootxyz/docker-netbootxyz/pull/73
Author: @rjocoleman
Created: 10/10/2024
Status: 🔄 Open
Base:
master← Head:proxydhcp📝 Commits (6)
25ef084use a config file for dnsmasqf36963fadd proxy-DHCP support via dnsmasqb326528Limit envsub to only variable being changed7c93323proxydhcp - get container IP differentlycfc13acupdate example MENU_VERSION43b5988proxydhcp: capabilities and network mode📊 Changes
6 files changed (+113 additions, -13 deletions)
View changed files
📝
README.md(+16 -8)📝
docker-compose.yml.example(+5 -1)➕
root/defaults/dnsmasq-dhcpproxy.conf(+66 -0)➕
root/defaults/dnsmasq.conf(+5 -0)📝
root/etc/supervisor.conf(+1 -1)📝
root/init.sh(+20 -3)📄 Description
This PR adds proxy-DHCP support:
What is proxy-DHCP?
Proxy-DHCP allows a secondary DHCP server to provide boot configuration (such as next-server and boot file) while the primary DHCP server continues to assign IP addresses. This is useful in environments where modifying the primary DHCP server is not feasible, or the primary DHCP server doesn't have a static IP.
How proxy-DHCP works
When a client sends out a DHCP request, the proxy-DHCP service will respond with boot options such as the next-server and boot filename, while leaving the IP address assignment to the primary DHCP server. This allows the client to chainload iPXE without requiring modifications to the existing DHCP server.
Pairs well with netboot.xyz PR #953
This PR works alongside #953, which adds support for proxy-DHCP in the iPXE menus, allowing users to press a key to select the proxy offer and load netboot.xyz from there.
How to use it
Set the
DHCP_RANGE_STARTenvironment variable to the first IP in your network’s DHCP range. This will enable the optional proxy-DHCP mode. When enabled, dnsmasq calculates the range and handles proxy requests automatically.Edit: Ensure the docker container is on the same network e.g.
--network host(or ipvlan, macvlan) so that it can receive broadcast DHCP messages and respond with its own broadcasts.Moved dnsmasq config to a file
To enable this functionality cleanly, the dnsmasq configuration has been moved into a config file, allowing for different config based on the presence of env
DHCP_RANGE_STARTand substitution of some values via envsubst.Proxy-DHCP behaviour
When
DHCP_RANGE_STARTis set, the provided dnsmasq will behave in proxy-DHCP mode (in addition to tftp), with the following key sections in the configuration:This configuration sets up the proxy-DHCP to respond only to PXE clients (non-iPXE), serving the appropriate bootloaders for BIOS, UEFI, ARM64, and Raspberry Pi clients, while iPXE clients will be served an HTTP boot script.
Dynamic IP handling with envsubst
The
CONTAINER_IPis dynamically injected into the configuration usingenvsubst, after retrieving the container’s IP address at runtime from the container itself viainit.sh. This ensures that the correct container next-server IP is set in the configuration.User experience
Users can start the container with the relevant environment variables set (
DHCP_RANGE_STARTand optionally others). When a DHCP request is detected, this container sends a proxy offer with the next-server and boot file. With PR #953, netboot.xyz will detect the proxy next-server, allowing users to presspto boot from the proxy-DHCP server.As it depends on a new env var being added
DHCP_RANGE_START, this should be backwards compatible.Docs & resources:
https://www.ipxe.org/appnote/proxydhcp
https://gist.github.com/NiKiZe/5c181471b96ac37a069af0a76688944d
https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.