How to enable DHCP

*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.

Enable MAAS DHCP

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 IP range

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 IP range

  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 IP range

  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 IP range

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.

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

DHCP relays

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.

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

DHCP snippets

To manage snippets:

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

  2. Select Settings >> DHCP snippets.

Search 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 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 snippets

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

Delete 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.

Global snippets

To create a global snippet:

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

Subnet snippets

To create a subnet snippet:

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

Node snippets

To create a node snippet:

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

List 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 snippets

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.

Toggle a 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 snippet

To delete a snippet:

maas $PROFILE dhcpsnippet delete $DHCP_SNIPPET_ID

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

DHCP ranges

These features are only available via the MAAS CLI

Create 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'

Protect a range

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'

Protect an IP

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

maas $PROFILE ipaddresses reserve ip_address=$IP_STATIC_SINGLE

Edit a 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 a 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

DNS records

These features are only available via the MAAS CLI

A/AAAA DNS records

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

CNAME DNS records

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

ME DNS records

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'

DNS forwarder

To set a DNS forwarder:

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

Last updated 7 days ago.