Skip to content

Migrating from dnsmasq to DRP DHCP

This tutorial walks through translating a dnsmasq configuration into equivalent DRP objects: Subnets and Reservations.

Disable dnsmasq before enabling DRP DHCP

Both services listen on UDP port 67. Running them simultaneously on the same interface will cause DHCP conflicts. Stop and disable dnsmasq before enabling DRP's DHCP server.

Directive Mapping Overview

dnsmasq directive DRP equivalent
dhcp-range Subnet ActiveStart, ActiveEnd, ActiveLeaseTime
dhcp-option Subnet or Reservation DHCP options
dhcp-host Reservation
domain / local DRP DNS Zone
address= Static record in a DRP Zone
interface / listen-address Determines which Subnet CIDR to create
no-dhcp-interface No Subnet needed for that interface

Converting dhcp-range to a Subnet

A dhcp-range line defines the dynamic address pool. Map its fields to a DRP Subnet as follows:

dnsmasq:

Text Only
dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h

DRP Subnet:

YAML
---
Name: my-network
Subnet: 192.168.1.0/24
ActiveStart: 192.168.1.100
ActiveEnd: 192.168.1.200
ActiveLeaseTime: 43200
ReservedLeaseTime: 7200
Enabled: true
Strategy: MAC
Pickers:
  - hint
  - nextFree
  - mostExpired

Bash
drpcli subnets create - <<EOF
Name: my-network
Subnet: 192.168.1.0/24
ActiveStart: 192.168.1.100
ActiveEnd: 192.168.1.200
ActiveLeaseTime: 43200
ReservedLeaseTime: 7200
Enabled: true
Strategy: MAC
Pickers:
  - hint
  - nextFree
  - mostExpired
EOF

Lease time conversion: dnsmasq accepts 12h, 1d, etc. Convert to seconds for DRP (12h = 43200, 1d = 86400). The minimum ActiveLeaseTime is 60 seconds; minimum ReservedLeaseTime is 7200 seconds.

Determining the Subnet CIDR

The Subnet field must be the network address with prefix length (e.g. 192.168.1.0/24). Derive this from the dhcp-range mask or from the interface address. It does not have to match the dynamic range exactly — the range is a subset of the subnet.

Converting dhcp-option to Subnet Options

dnsmasq dhcp-option lines map to DHCP option numbers in DRP. The most common options:

dnsmasq option Option # DRP type Example value
option:router / 3 3 IP 192.168.1.1
option:dns-server / 6 6 IP 8.8.8.8
option:domain-name / 15 15 String example.com
option:ntp-server / 42 42 IP 192.168.1.1
option:netmask / 1 1 IP 255.255.255.0

dnsmasq:

Text Only
dhcp-option=3,192.168.1.1
dhcp-option=6,8.8.8.8,8.8.4.4
dhcp-option=15,example.com

DRP Subnet with Options:

YAML
---
Name: my-network
Subnet: 192.168.1.0/24
ActiveStart: 192.168.1.100
ActiveEnd: 192.168.1.200
ActiveLeaseTime: 43200
Enabled: true
Options:
  - Code: 3
    Value: 192.168.1.1
  - Code: 6
    Value: 8.8.8.8
  - Code: 6
    Value: 8.8.4.4
  - Code: 15
    Value: example.com
Strategy: MAC
Pickers:
  - hint
  - nextFree
  - mostExpired

Add options to an existing subnet:

Bash
drpcli subnets patch my-network '[
  {"op":"add","path":"/Options/-","value":{"Code":3,"Value":"192.168.1.1"}},
  {"op":"add","path":"/Options/-","value":{"Code":6,"Value":"8.8.8.8"}},
  {"op":"add","path":"/Options/-","value":{"Code":15,"Value":"example.com"}}
]'

Converting dhcp-host to Reservations

Each dhcp-host line becomes a DRP Reservation. The MAC address becomes the Token and the IP becomes Addr.

dnsmasq:

Text Only
dhcp-host=11:22:33:44:55:66,192.168.1.50,webserver01,12h
dhcp-host=aa:bb:cc:dd:ee:ff,192.168.1.51

DRP Reservations:

Bash
drpcli reservations create - <<EOF
Token: "11:22:33:44:55:66"
Addr: 192.168.1.50
Strategy: MAC
Duration: 43200
Options:
  - Code: 12
    Value: webserver01
EOF

drpcli reservations create - <<EOF
Token: "aa:bb:cc:dd:ee:ff"
Addr: 192.168.1.51
Strategy: MAC
EOF

Note

Option 12 is the DHCP hostname. If your dhcp-host line includes a hostname, set it as option 12 on the reservation. If the reservation's subnet also has option 15 (domain name) set, DRP will automatically create DNS A and PTR records for the host.

Note

A reservation responds to DHCP requests even if its subnet is disabled. This matches dnsmasq behavior where dhcp-host entries outside the dhcp-range still receive responses.

Complete Example

Sample dnsmasq.conf:

Text Only
interface=eth0
domain=lab.internal

dhcp-range=10.0.0.100,10.0.0.200,255.255.255.0,24h
dhcp-option=3,10.0.0.1
dhcp-option=6,10.0.0.1
dhcp-option=15,lab.internal

dhcp-host=de:ad:be:ef:00:01,10.0.0.10,node01,infinite
dhcp-host=de:ad:be:ef:00:02,10.0.0.11,node02,infinite
dhcp-host=de:ad:be:ef:00:03,10.0.0.12,node03,infinite

Step 1 — Create the subnet:

Bash
drpcli subnets create - <<EOF
Name: lab-internal
Subnet: 10.0.0.0/24
ActiveStart: 10.0.0.100
ActiveEnd: 10.0.0.200
ActiveLeaseTime: 86400
ReservedLeaseTime: 86400
Enabled: true
Strategy: MAC
Pickers:
  - hint
  - nextFree
  - mostExpired
Options:
  - Code: 3
    Value: 10.0.0.1
  - Code: 6
    Value: 10.0.0.1
  - Code: 15
    Value: lab.internal
EOF

Step 2 — Create reservations for static hosts:

Bash
for entry in \
  "de:ad:be:ef:00:01,10.0.0.10,node01" \
  "de:ad:be:ef:00:02,10.0.0.11,node02" \
  "de:ad:be:ef:00:03,10.0.0.12,node03"; do
  mac=$(echo $entry | cut -d, -f1)
  ip=$(echo $entry | cut -d, -f2)
  host=$(echo $entry | cut -d, -f3)
  drpcli reservations create - <<EOF
Token: "$mac"
Addr: $ip
Strategy: MAC
Options:
  - Code: 12
    Value: $host
EOF
done

Step 3 — Verify:

Bash
drpcli subnets show lab-internal --format=yaml
drpcli reservations list

Step 4 — Stop dnsmasq and enable DRP DHCP:

Bash
sudo systemctl stop dnsmasq
sudo systemctl disable dnsmasq
# DRP DHCP is enabled by default; restart DRP if needed
sudo systemctl restart dr-provision

Handling Multiple Interfaces

If your dnsmasq config binds to multiple interfaces or has multiple dhcp-range lines for different networks, create one Subnet per network range. Each subnet must have a unique Name and non-overlapping Subnet CIDR.

dnsmasq:

Text Only
dhcp-range=192.168.1.100,192.168.1.200,24h
dhcp-range=10.10.0.100,10.10.0.200,24h

Create two subnets:

Bash
drpcli subnets create - <<EOF
Name: network-192-168-1
Subnet: 192.168.1.0/24
ActiveStart: 192.168.1.100
ActiveEnd: 192.168.1.200
ActiveLeaseTime: 86400
Enabled: true
Strategy: MAC
Pickers: [hint, nextFree, mostExpired]
EOF

drpcli subnets create - <<EOF
Name: network-10-10-0
Subnet: 10.10.0.0/24
ActiveStart: 10.10.0.100
ActiveEnd: 10.10.0.200
ActiveLeaseTime: 86400
Enabled: true
Strategy: MAC
Pickers: [hint, nextFree, mostExpired]
EOF

See Also