Most network administrators know how to set up a basic DHCP server – a pool of addresses, a gateway, and DNS servers. But MikroTik's DHCP server has many advanced features: Option 82 for relay agent information, static leases for fixed IPs, custom options for PXE boot or VoIP phones, and DHCP relay to serve multiple subnets. This guide takes you beyond the basics.
When Do You Need Advanced DHCP?
- Your ISP infrastructure uses DHCP relay with circuit‑ID (Option 82) for per‑customer IP assignment.
- You need IP phones to receive a specific TFTP server address via DHCP.
- You want a device always to receive the same IP without manual configuration.
- You have a central DHCP server serving multiple VLANs via a relay.
Prerequisites
- A MikroTik router with a basic DHCP server already configured.
- WinBox or SSH access.
- For Option 82: a switch or router that supports DHCP relay with circuit‑ID added.
1. Static DHCP Leases (Reserving IPs)
Assign a fixed IP address to a specific MAC address – ideal for printers, servers, or management interfaces.
/ip dhcp-server lease add address=192.168.88.50 mac-address=AA:BB:CC:DD:EE:FF server=dhcp1 comment="Network printer"
You can also set a static lease via WinBox: IP → DHCP Server → Leases, right‑click an active lease and choose Make Static. Then adjust the IP if needed.
The dhcp1 server name comes from your existing DHCP server. To view server names:
/ip dhcp-server print
2. Custom DHCP Options (PXE, TFTP, VoIP)
Custom options allow you to send additional parameters to clients – for example, a PXE boot server address or a VoIP provisioning server.
2.1 Define a custom option
First, create a new option code. For PXE boot, Option 66 (TFTP server name) and Option 67 (boot file name) are common.
/ip dhcp-server option add name=tftp-server code=66 value="192.168.88.10"
2.2 Apply the option to a network
/ip dhcp-server network set 0 dhcp-option=tftp-server
You can set multiple options by listing them space‑separated.
2.3 For VoIP phones (Option 150 – TFTP server list)
/ip dhcp-server option add name=voip-tftp code=150 value="192.168.88.20" raw-value=yes
raw-value=yes tells RouterOS to send the value as raw bytes (no encapsulation).
3. DHCP Relay – Serving Remote Subnets
When your DHCP server is in one subnet but needs to serve clients in another (e.g., different VLAN or remote office), use a DHCP relay. The relay agent forwards broadcast DHCP requests to the server's unicast IP.
3.1: On a MikroTik acting as relay (e.g., a remote router or switch)
/ip dhcp-relay add name=relay-to-central interface=vlan10 dhcp-server=192.168.1.100 local-address=192.168.1.2
interface is the interface where clients are located (e.g., VLAN 10). dhcp-server is the central DHCP server's IP. local-address is the relay's own IP on that network (optional but recommended).
Enable the relay:
/ip dhcp-relay set 0 disabled=no
3.2: On the central DHCP server
You need to define a DHCP network for the remote subnet (the pool that the relay serves). For example, if remote subnet is 10.10.10.0/24:
/ip dhcp-server network add address=10.10.10.0/24 gateway=10.10.10.1 dns-server=8.8.8.8
And an IP pool for that subnet:
/ip pool add name=pool-remote ranges=10.10.10.100-10.10.10.200
/ip dhcp-server add name=dhcp-remote interface=bridge-main address-pool=pool-remote disabled=no
The relay forwards requests, and the central server responds.
4. DHCP Option 82 (Relay Agent Information)
Option 82 allows the DHCP relay to add information like the circuit ID (which physical port the client is connected to) and remote ID (which relay device). This is heavily used by ISPs to map customers to specific IP pools or VLANs based on physical port.
4.1: Configuring Option 82 on the relay device
On your MikroTik acting as a DHCP relay, enable Option 82:
/ip dhcp-relay set relay0 use-agent-circuit-id=yes
You can also add custom circuit ID or remote ID strings:
/ip dhcp-relay set relay0 agent-circuit-id="Port1" agent-remote-id="Switch1"
4.2: Using Option 82 on the DHCP server
On the central MikroTik DHCP server, you can match incoming Option 82 values to assign specific IPs, pools, or options. Create a static lease that matches the circuit ID:
/ip dhcp-server lease add address=10.10.10.50 circuit-id="Port1" server=dhcp-remote
You can also use scripts to parse Option 82 and assign different pools. This enables per‑port IP assignment – each customer's physical port gets the same IP every time.
5. Advanced Pool Management (Used-Up Addresses)
When a DHCP pool runs out of addresses, the server logs a "no free lease" error. To prevent this, monitor usage and expand the pool, or implement shorter lease times (e.g., 10 minutes for guest networks).
/ip pool print usage
/ip pool set 0 next-pool=pool2
next-pool cascades to another pool when the first is full.
6. DHCP Alerts and Scripting
You can run a script when a new lease is granted. For example, to log every new IP assignment:
/system script add name=dhcp-log source=":log info \"DHCP assigned \$[/ip dhcp-server lease get [find status=bound binding-time] address] to \$[/ip dhcp-server lease get [find status=bound] mac-address]\""
/ip dhcp-server set dhcp1 lease-script=dhcp-log
Troubleshooting Advanced DHCP
- Static lease not working: Ensure the MAC address is entered correctly with colons (AA:BB:CC:DD:EE:FF). Also, check that no other lease has the same IP. Disable any conflicting dynamic leases.
- Custom options not being sent: Use Wireshark or
/tool snifferto inspect DHCP packets. Verify the option code is not already used. For raw values, ensureraw-value=yesfor hex data. - DHCP relay not forwarding: Check that the relay interface IP is reachable to the central DHCP server (ping). Firewall must allow UDP port 67 between the relay and the server. Also, the relay's
local-addressmust be an IP address on the relay’s outgoing interface. - Option 82 not being used in lease assignment: The server’s lease matching circuit‑id works only if the relay actually adds the option. Use
/ip dhcp-server lease print detailto see the stored circuit-id. If missing, enable it on the relay side.
Real‑World Use Cases
ISP Fiber/Cable Network
Each customer connects to a specific port on a MikroTik switch (or a simple bridge with VLANs). The switch acts as a DHCP relay, adding Option 82 with the port number. The central DHCP server assigns a fixed /32 IP to that circuit‑ID. No need for per‑customer static MAC entries.
School with 50 VLANs
One central MikroTik router serves all VLANs via DHCP relay on the core switch. The router has separate pools and networks for each VLAN. The relay forwards requests from all VLANs without additional configuration.
PXE Network Boot Environment
In a data center, the MikroTik router assigns Option 66 (TFTP server) and Option 67 (boot file) so that servers network‑boot automatically. Custom options are defined and applied to the server deployment VLAN.
Conclusion
MikroTik's DHCP server is surprisingly deep. Static leases provide predictable addressing; custom options deliver vendor‑specific parameters; DHCP relay centralises management; and Option 82 enables per‑circuit identity (especially valuable for ISPs). Start by adding static leases for your critical devices, then experiment with custom options. For larger networks, implement a relay architecture and optionally Option 82 for granular control.
Next steps: explore DHCPv6 for prefix delegation (IPv6), or combine DHCP relay with RADIUS for dynamic per‑user IP assignment (requires RADIUS, not covered here).