Offline docs (switch to live docs)                          UI-only  CLI-only

How to enable DHCP

Managing DHCP and IP ranges in MAAS

Errors or typos? Topics missing? Hard to read? Let us know!

Effective DHCP and IP range management is crucial. Mishandling this step is the most common cause of MAAS operational issues. If you're somewhat new to the subject, you might find it helpful to first read an overview of MAAS DHCP.

This chapter is divided into two main sections to assist you:

  1. Enabling DHCP through the UI
  2. Enabling DHCP via the CLI

These sections will equip you with the skills and knowledge to efficiently manage DHCP settings and IP ranges in MAAS.

Enabling DHCP through the UI

Navigating through the MAAS user interface offers an intuitive way to manage DHCP settings. Below are topics that guide you through key functionalities available in the UI:

By the end of this list, you'll have a solid grasp of DHCP management through the MAAS UI, setting you up for a streamlined network configuration.

Enable MAAS-managed DHCP with the UI

To enable MAAS-managed DHCP:

  1. Select Subnets.

  2. Select the desired VLAN.

  3. Scroll down to Reserved ranges.

  4. If there is no reserved dynamic range, select Reserved dynamic range from the drop-down on the right.

  5. Enter a Start IP address.

  6. Enter an End IP address.

  7. Select Reserve.

  8. Select Configure DHCP. You will see a new screen.

  9. The options MAAS provides DHCP and Provide DHCP from a rack controller will be pre-selected.

  10. If you accept these options, you may need to choose a Rack controller.

  11. If you choose Relay to another VLAN, you will need to choose the target VLAN.

  12. Under Reserved dynamic range, you may have to select a subnet from the drop-down.

  13. You will need to select Configure DHCP for your changes to be registered with MAAS.

Create an IP range via the UI

To create an IP range:

  1. Select Subnets.

  2. In the SUBNET column, choose the subnet for which you want to create an IP range.

  3. Scroll down to Reserved ranges.

  4. Select Reserve range and choose either Reserve range or Reserve dynamic range. Note that if you choose a dynamic range, MAAS will automatically provide DHCP for enlistment and commissioning provided that the associated VLAN has DHCP enabled.

  5. A window will appear, allowing you to enter a Start IP address and End IP address

  6. If you didn't select a dynamic range, you may optionally enter a Purpose for the range.

  7. Select Reserve to register your choices with MAAS.

Edit an existing IP range in the UI

  1. Select Menu at the far right of the row corresponding to the subnet in question.

  2. Select Edit reserved range from the menu that appears.

  3. Edit the fields as desired.

  4. Select Save to register your changes.

Delete an existing IP range from the UI

  1. Select Menu at the far right of the row corresponding to the subnet in question.

  2. Select Remove range from the menu that appears.

  3. Select Save to register your changes.

Extend a reserved dynamic IP range using the UI

To extend a dynamic IP range:

  1. Go to Subnets.

  2. Select the relevant subnet.

  3. Reserve a dynamic range.

DHCP will be enabled automatically.

Utilise a DHCP relay from the UI

To relay from one VLAN (source) to another VLAN (target):

  1. Ensure the target VLAN has DHCP enabled.

  2. Set up the external relay. This relay is set up independently from MAAS. See DHCP relay for software suggestions.

  3. Configure MAAS-managed DHCP as normal.

  4. Navigate to the source VLAN page.

  5. Select the Relay DHCP action.

  6. Fill in the fields in the resulting form. Note that the crucial setting is the target VLAN (Relay VLAN).

  7. Select Relay DHCP to finish.

Customise MAAS with DHCP snippets through the UI

Manage DHCP snippets

To manage snippets:

  1. Make sure you are logged in as an administrator.

  2. Select Settings >> DHCP snippets.

Search DHCP snippets

To search DHCP snippets, enter the text to match in Search DHCP snippets. MAAS will progressively update the list of snippets as you type your search terms.

Add DHCP snippets

To add a snippet:

  1. Select Add snippet.

  2. Enter the Snippet name.

  3. Optionally, check Enabled to enable the snippet now. Note that MAAS will not apply the snippet unless it is enabled.

  4. Optionally, enter a Description for the snippet.

  5. Optionally, choose a Type for the snippet from the drop-down (defaults to Global). This parameter sets the scope of the snippet. Note that if you choose a type other than global, you may need to choose the specific scope. For example, if you choose the Subnet type, you must identify the specific subnet to which this snippet applies.

  6. Enter the DHCP snippet. This is not validated on entry.

  7. Select Save snippet to register your changes with MAAS

Edit DHCP snippets

To edit a snippet, select the pencil icon to the right of the snippet row and edit the fields as desired.

Delete DHCP snippets

To delete a snippet, select the trash can icon to the right of the snippet. You will be asked to confirm; be aware that once confirmed, this action cannot be undone.

Enabling DHCP via the CLI

For those who prefer using the command-line interface, MAAS offers a robust set of tools to manage your DHCP settings and DNS records with greater granularity. The following topics are covered:

By navigating through this list, you'll gain comprehensive knowledge on how to leverage the CLI for advanced DHCP and DNS configurations in MAAS.

Enable MAAS-managed DHCP

To enable DHCP on a VLAN in a certain fabric, enter the following command:

maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True \
    primary_rack=$PRIMARY_RACK_CONTROLLER

To enable DHCP HA, you will need both a primary and a secondary controller:

maas $PROFILE vlan update $FABRIC_ID $VLAN_TAG dhcp_on=True \
    primary_rack=$PRIMARY_RACK_CONTROLLER \
    secondary_rack=$SECONDARY_RACK_CONTROLLER 

Pro tip: You must enable DHCP for PXE booting on the 'untagged' VLAN.

You will also need to set a default gateway:

maas $PROFILE subnet update $SUBNET_CIDR gateway_ip=$MY_GATEWAY

Create an IP range

To create a range of dynamic IP addresses that will be used by MAAS for node enlistment, commissioning, and possibly deployment:

maas $PROFILE ipranges create type=dynamic \
    start_ip=$IP_DYNAMIC_RANGE_LOW end_ip=$IP_DYNAMIC_RANGE_HIGH \
    comment='This is a reserved dynamic range'

Create a range of IP addresses not used by MAAS

To create a range of IP addresses that will not be used by MAAS:

maas $PROFILE ipranges create type=reserved \
    start_ip=$IP_STATIC_RANGE_LOW end_ip=$IP_STATIC_RANGE_HIGH \
    comment='This is a reserved range'

Reserve a single IP address that will not be used by MAAS

To reserve a single IP address that will not be used by MAAS:

maas $PROFILE ipaddresses reserve ip_address=$IP_STATIC_SINGLE

Edit an existing IP range

To edit an IP range:

  1. Find the ID of the desired IP range with the command:
maas admin ipranges read
  1. Edit the range with the command:
maas admin iprange update $ID start_ip="<start ip>" end_ip="<end ip>" comment="freeform comment"

This command will update the IP range associated with $ID.

Delete an existing IP range

You can delete a range of IP addresses by deleting the addresses one by one. To remove a single reserved IP address:

maas $PROFILE ipaddresses release ip=$IP_STATIC_SINGLE

Utilise a DHCP relay

To relay DHCP traffic for a VLAN (source) through another VLAN (target):

maas $PROFILE vlan update $FABRIC_ID $VLAN_VID_SRC relay_vlan=$VLAN_ID_TARGET

For example, to relay VLAN with vid 0 (on fabric-2) through VLAN with id 5002 :

maas $PROFILE vlan update 2 0 relay_van=5002

Customise MAAS with DHCP snippets

Create a global DHCP snippet

To create a global snippet:

maas $PROFILE dhcpsnippets create name=$DHCP_SNIPPET_NAME \
    value=$DHCP_CONFIG description=$DHCP_SNIPPET_DESCRIPTION \
    global_snippet=true

Create a subnet DHCP snippet

To create a subnet snippet:

maas $PROFILE dhcpsnippets create name=$DHCP_SNIPPET_NAME \
    value=$DHCP_CONFIG description=$DHCP_SNIPPET_DESCRIPTION \
    subnet=$SUBNET_ID

Create a node DHCP snippet

To create a node snippet:

maas $PROFILE dhcpsnippets create name=$DHCP_SNIPPET_NAME \
    value=$DHCP_CONFIG description=$DHCP_SNIPPET_DESCRIPTION \
    node=$NODE_ID

List DHCP snippets

To list all snippets (and their characteristics) in the MAAS:

maas $PROFILE dhcpsnippets read

To list a specific snippet:

maas $PROFILE dhcpsnippet read id=$DHCP_SNIPPET_ID

The snippet name can also be used instead of its ID:

maas $PROFILE dhcpsnippet read name=$DHCP_SNIPPET_NAME

Update a DHCP snippet

To update a DHCP snippet attribute:

maas $PROFILE dhcpsnippet update $DHCP_SNIPPET_ID <option=value>

You can also use a snippet name instead of its ID.

Enable or disable a DHCP snippet

Enabling and disabling a snippet is considered a snippet update and is done via a Boolean option ('true' or 'false'). You can disable a snippet like this:

maas $PROFILE dhcpsnippet update $DHCP_SNIPPET_ID enabled=false

When you disable a snippet, MAAS removes the text you added to the dhcpd.conf file when you created the snippet.

Delete a DHCP snippet

To delete a snippet:

maas $PROFILE dhcpsnippet delete $DHCP_SNIPPET_ID

You can also use a snippet name in place of its ID.

Create an A or AAAA record in DNS

It is possible to set DNS parameters using the MAAS CLI, using the following instructions.

Create an A or AAAA record in DNS

An administrator can create an A record when creating a DNS resource with an IPv4 address:

mass $PROFILE dnsresources create fqdn=$HOSTNAME.$DOMAIN ip_addresses=$IPV4ADDRESS

An administrator can also create an AAAA record when creating a DNS resource with an IPv6 address:

mass $PROFILE dnsresources create fqdn=$HOSTNAME.$DOMAIN ip_addresses=$IPV6ADDRESS

Create an alias (CNAME) record in DNS

An administrator can set a DNS Alias (CNAME record) to an already existing DNS entry of a machine:

mass $PROFILE dnsresource-records create fqdn=$HOSTNAME.$DOMAIN rrtype=cname rrdata=$ALIAS

For example, to set webserver.maas.io to alias to www.maas.io:

maas $PROFILE dnsresource-records create fqdn=webserver.maas.io rrtype=cname rrdata=www

Create a Mail Exchange pointer record in DNS

An administrator can set a DNS Mail Exchange pointer record (MX and value) to a domain:

maas $PROFILE dnsresource-records create fqdn=$DOMAIN rrtype=mx rrdata='10 $MAIL_SERVER.$DOMAIN'

For example, to set the domain.name managed by MAAS to have an MX record and that you own the domain:

maas $PROFILE dnsresource-records create fqdn=maas.io rrtype=mx rrdata='10 smtp.maas.io'

Set a DNS forwarder

To set a DNS forwarder:

maas $PROFILE maas set-config name=upstream_dns value=$MY_UPSTREAM_DNS