Syncs IPv4 Subnet, Ranges and Reservations from Netbox into a Windows DHCP server.
Als Prefixes match the filter will be created as Scope on the DHCP server. Each Prefix needs a corresponding IP-Range which defines the pool. IP-Addresses matching the filter within a Prefix will be set as reservations.
To set the Prefix/Subnet DHCP lease duration a Integer Custom Field dhcp_lease_duration
on the Ipam>Prefix can be added to override the default lease duration on a per Prefix/Subnet basis.
To set the Prefix/Subnet DNS settings a Multiple selection Custom Field dhcp_dns_flags
with the choises ['enabled', 'update_downlevel', 'cleanup_expired', 'update_both_always', 'update_dhcid', 'disable_ptr_update', 'disabled']
on the Ipam>Prefix can be added to override the default on a per Prefix/Subnet basis.
To make a reservation without a Device to assigne the IP-Address to a Text Custom Field dhcp_reservation_mac
can be added to provide the MAC address.
The Hook Server can run as a Windows Servive to listen for WebHooks from Netbox. The Sync is started by an Intervall and on receiving Hooks. Multiple hooks in short succession will only trigger one sync.
The configfile is read from C:\ProgramData\netbox_windhcp\netbox_windhcp.cfg
---
webhook:
listen: 0.0.0.0:6969
sync:
dhcp:
server: dhcp.example.com
default_dns_flags:
enabled: true
cleanup_expired: true
update_dhcid: true
netbox:
apiurl: https://netbox.example.ch/api/
token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
prefix_filter:
tag: dhcp
state: active
range_filter:
role: dhcp-pool
state: active
reservation_filter:
tag: dhcp
log:
dir: C:\ProgramData\netbox_windhcp\
level: Info
max_size: 10240000
keep_logs: 10
- Install Rust with Rust-Up
- Compile with
cargo build
- Test run with
cargo run --bin netbox-windhcp-sync -- --noop
- Build MSI with
cargo wix