This adds a new dhcp server resource, as well as a dhcp host resource used to specify the static mapping between mac address and ip address. It also adds a simple, pure-golang example dhcp client which might make testing easier. The dhcp resource is not meant to be a full-featured dhcp server replacement, and it might still be useful to use the venerable dhcpd, however for integrated, pure-golang bootstrapping environments, this might prove to be very useful. It can be combined with the tftp resource to build PXE setups with mgmt. This resource can be extended further to support a dhcp:range directive, automatic edges, and more!
27 lines
700 B
Plaintext
27 lines
700 B
Plaintext
$iface = "lo" # replace with your desired interface like eth0
|
|
|
|
net $iface {
|
|
state => "up",
|
|
addrs => ["192.168.42.1/24",],
|
|
}
|
|
|
|
dhcp:server ":67" {
|
|
interface => $iface, # required for now
|
|
leasetime => "60s", # increase this for normal production
|
|
dns => ["8.8.8.8", "1.1.1.1",], # pick your own better ones!
|
|
routers => ["192.168.42.1",],
|
|
|
|
Depend => Net[$iface], # TODO: add autoedges
|
|
}
|
|
|
|
dhcp:host "hostname1" {
|
|
mac => "00:11:22:33:44:55", # replace with your own!
|
|
ip => "192.168.42.101/24", # cidr notation is required
|
|
}
|
|
|
|
dhcp:host "hostname2" {
|
|
mac => "ba:98:76:54:32:11", # replace with your own!
|
|
ip => "192.168.42.102/24",
|
|
nbp => "tftp://192.168.42.1/pxelinux.0", # for bios clients
|
|
}
|