Basic DHCP Server Setup
Basic DHCP Server Setup
Section titled “Basic DHCP Server Setup”TL;DR (Quick Start)
Section titled “TL;DR (Quick Start)”For the impatient: here’s the 30-second version.
# Minimal DHCP server on ether2/ip address add address=192.168.88.1/24 interface=ether2/ip pool add name=dhcp-pool ranges=192.168.88.10-192.168.88.254/ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1/ip dhcp-server add name=dhcp-lan interface=ether2 address-pool=dhcp-pool lease-time=1d disabled=noOverview
Section titled “Overview”This guide demonstrates how to configure a basic DHCP server on MikroTik RouterOS to automatically distribute IP addresses to devices on your local network. A DHCP server eliminates the need to manually configure IP addresses on each client device.
Prerequisites
Section titled “Prerequisites”- A MikroTik router running RouterOS 7.x or later
- An interface configured with a static IP address (this will be the gateway)
- Access to the router via SSH, WinBox, or WebFig
Note: In this example, we use
ether2as the LAN interface. In a staging environment,ether1is typically reserved for management/WAN access.
Configuration Steps
Section titled “Configuration Steps”Step 1: Assign an IP Address to the Interface
Section titled “Step 1: Assign an IP Address to the Interface”Before configuring the DHCP server, ensure the interface has a static IP address. This address will serve as the gateway for DHCP clients.
/ip address add address=192.168.88.1/24 interface=ether2 comment="LAN Gateway"This assigns 192.168.88.1 with a /24 subnet mask to ether2 (LAN interface).
Step 2: Create an IP Address Pool
Section titled “Step 2: Create an IP Address Pool”Create a pool of IP addresses that the DHCP server will distribute to clients. The pool should NOT include the gateway address.
/ip pool add name=dhcp-pool ranges=192.168.88.10-192.168.88.254This creates a pool named “dhcp-pool” with addresses from 192.168.88.10 to 192.168.88.254 (245 available addresses).
Step 3: Configure the DHCP Network
Section titled “Step 3: Configure the DHCP Network”Define the network parameters that will be sent to DHCP clients, including the gateway and DNS servers.
/ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1 comment="LAN Network"This tells clients:
- Their network is 192.168.88.0/24
- The gateway is 192.168.88.1
- The DNS server is 192.168.88.1 (the router itself)
Step 4: Create the DHCP Server
Section titled “Step 4: Create the DHCP Server”Create the DHCP server and bind it to the interface and address pool.
/ip dhcp-server add name=dhcp-lan interface=ether2 address-pool=dhcp-pool lease-time=1d disabled=noThis creates a DHCP server named “dhcp-lan” on ether2 with a 1-day lease time.
Verification
Section titled “Verification”Confirm your DHCP server is working by running these commands:
Check 1: Verify DHCP Server Status
Section titled “Check 1: Verify DHCP Server Status”/ip dhcp-server printExpected Output:
Flags: D - dynamic, X - disabled, I - invalid # NAME INTERFACE RELAY ADDRESS-POOL LEASE-TIME ADD-ARP 0 dhcp-lan ether2 dhcp-pool 1d noThe server should appear without the “X” (disabled) flag.
Check 2: Verify IP Pool Configuration
Section titled “Check 2: Verify IP Pool Configuration”/ip pool printExpected Output:
# NAME RANGES 0 dhcp-pool 192.168.88.10-192.168.88.254Check 3: Verify Network Configuration
Section titled “Check 3: Verify Network Configuration”/ip dhcp-server network printExpected Output:
# ADDRESS GATEWAY DNS-SERVER 0 192.168.88.0/24 192.168.88.1 192.168.88.1Check 4: View Active Leases (after clients connect)
Section titled “Check 4: View Active Leases (after clients connect)”/ip dhcp-server lease printExpected Output (when clients are connected):
Flags: D - dynamic, B - blocked # ADDRESS MAC-ADDRESS HOST-NAME SERVER STATUS 0 D 192.168.88.10 AA:BB:CC:DD:EE:FF client1 dhcp-lan boundTroubleshooting
Section titled “Troubleshooting”Problem: DHCP server shows as disabled
Section titled “Problem: DHCP server shows as disabled”Solution: Enable the server with /ip dhcp-server enable dhcp-lan
Problem: Clients not receiving IP addresses
Section titled “Problem: Clients not receiving IP addresses”Solution:
- Verify the interface name is correct
- Check that the address pool has available addresses
- Ensure no firewall rules are blocking DHCP traffic (UDP ports 67-68)
Problem: Clients receive IP but cannot access the internet
Section titled “Problem: Clients receive IP but cannot access the internet”Solution:
- Verify NAT masquerade is configured for the interface
- Check that the gateway address is correct in the network configuration
- Ensure DNS is working:
/ip dns print
Problem: “no free addresses” error
Section titled “Problem: “no free addresses” error”Solution:
- Increase the pool range
- Reduce the lease time to free up addresses faster
- Remove stale leases:
/ip dhcp-server lease remove [find status=waiting]
Related Topics
Section titled “Related Topics”Prerequisites
Section titled “Prerequisites”- IP Address Configuration - the interface must have a static IP before configuring DHCP
Next Steps
Section titled “Next Steps”- DNS Server - configure local DNS resolution for DHCP clients
- NAT Masquerade - enable internet access for DHCP clients
- Firewall Basics - secure your network
Related DHCP Topics
Section titled “Related DHCP Topics”- DHCP Client - obtain IP address from upstream DHCP server
- DHCP Relay - forward DHCP requests across network segments
- IP Pools - advanced pool configuration options
IPv6 Alternative
Section titled “IPv6 Alternative”- DHCPv6 Server - IPv6 address distribution