DHCP snippet

In MAAS, DHCP snippets are user-defined configurations that modify the behavior of the DHCP service provided by MAAS. They allow for custom per-subnet, per-machine, or global DHCP configurations, enabling fine-grained control over network settings.

Use cases

  • Defining custom DHCP options (e.g., PXE boot parameters, static routes).
  • Assigning specific IP addresses or lease durations to certain machines.
  • Customizing DHCP behavior based on device type, vendor class, or other attributes.

Configuration

  • DHCP snippets are written in ISC DHCP format.
  • They can be added via the MAAS UI or CLI (maas <profile> dhcp-snippet create).
  • Snippets can be scoped to global settings, a VLAN, or a specific machine.

Example snippet

if exists user-class and option user-class = "iPXE" {
    filename "http://10.0.0.1/boot.ipxe";
} else {
    filename "pxelinux.0";
}

This snippet directs iPXE-enabled clients to fetch a custom boot script while defaulting others to pxelinux.0.

Key considerations

  • Snippets must follow ISC DHCP syntax to avoid breaking the service.
  • Improper snippets can cause DHCP failures or unexpected network behavior.
  • MAAS does not validate snippet correctness, so testing is recommended.

Last updated 16 hours ago.