DHCP · Topic 1 of 2
DHCP Client, DHCP Server and Lease Management
Configure the RouterOS DHCP client and DHCP server, set the network options handed to hosts, and manage dynamic and static leases from the console.
- 5 min
- A DHCP client is added per interface with
/ip dhcp-client add interface=ether1 disable=no. - A DHCP server needs an interface, an address pool and a network entry.
/ip dhcp-server setupcreates all the parts through a short wizard.
What it is
DHCP hands out IP settings automatically, and a RouterOS device can be the client, the server or both.
As a client, the router asks a provider for an address. As a server, it gives addresses to the hosts on a LAN. The server keeps a record of each address it hands out, called a lease.
A DHCP server needs three things: an interface to listen on, a pool of addresses, and a network entry that says which gateway and DNS server clients receive.
How it works
The client and server follow the same four steps, and RouterOS exposes each piece as a menu.
DHCP client
The client is configured per interface, usually on the WAN port.
/ip dhcp-client add interface=ether1 disable=no
/ip dhcp-client print
The print output shows the status, such as searching or bound, together with the address and the server that granted it. Several parameters shape what the client does with the reply:
| Parameter | Effect |
|---|---|
add-default-route | Adds a default route through the gateway that the server offers |
use-peer-dns | Uses the DNS servers that the server offers |
use-peer-ntp | Uses the time servers that the server offers |
A client can be released and renewed from the console. The address, the gateway and the route it created all disappear when the client is disabled or removed.
DHCP server setup
The quickest way to build a server is the setup command, which asks questions and creates every piece for you.
/ip dhcp-server setup
It asks for the interface to serve, the address space, the gateway, the address pool, the DNS servers and the lease time. The LAN interface must already have an IP address in the subnet that you serve.
The same result can be built by hand from three parts.
/ip pool add name=lan-pool ranges=192.168.88.10-192.168.88.200
/ip dhcp-server add name=dhcp1 interface=ether2 address-pool=lan-pool disabled=no
/ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1
The pool holds the addresses available for clients. The server entry ties a pool to an interface. The network entry says what extra settings a client receives.
A new server entry is disabled until you enable it, and a server on an interface with no matching IP address will not work.
DHCP server network configuration
The network entry is how you control the options in each reply. It matches by subnet.
| Parameter | What clients receive |
|---|---|
address | The subnet this entry applies to |
gateway | The default gateway |
dns-server | The DNS server or servers |
domain | A domain name |
ntp-server | A time server |
Without a network entry, clients may receive an address but no gateway or DNS server. They would then reach the local subnet but not the Internet.
Leases management
Every address given out appears in the lease table.
/ip dhcp-server lease print
/ip dhcp-server lease make-static 0
/ip dhcp-server lease add address=192.168.88.50 mac-address=00:0C:42:AA:BB:CC server=dhcp1
/ip dhcp-server lease remove 0
A lease is dynamic when the server created it, and it expires if the client does not renew it. A static lease ties one MAC address to one IP address, so that host always gets the same address.
The make-static command turns a dynamic lease into a static one. A static lease should use an address that is outside the dynamic pool, or at least not in use by another host.
Lease status tells you what is happening:
- bound means the client has the address now.
- waiting means the lease exists but the client is not active.
- offered means the server has offered the address but the client has not accepted yet.
The lease time is how long a lease is valid before the client must renew it. A short time recycles addresses quickly. A long time keeps addresses stable but holds them longer after a host leaves.
Give servers and printers static leases so that their addresses never change, and keep the pool for ordinary clients.
What to remember for the exam
Seven facts cover this topic.
- A DHCP client is added per interface with
/ip dhcp-client add interface=ether1 disable=no. - A DHCP server needs an interface, an address pool and a network entry.
/ip dhcp-server setupcreates all the parts through a short wizard.- The network entry supplies the gateway, DNS server and other options.
- A new server must be enabled before it hands out addresses.
- A static lease ties a MAC address to an IP address.
/ip dhcp-server lease printshows each lease and its status.
Common mistakes
These four mistakes break a DHCP server.
Forgetting the network entry. Clients get an address but no gateway or DNS, so they cannot reach the Internet.
Serving an interface with no IP address. The server has no subnet to work from, so the setup fails or stays idle.
Leaving the server disabled. The entry exists but never answers until it is enabled.
Using a static lease address inside the active pool. Another client may already hold it, which causes a conflict.
Check yourself
Work through these three questions.
Which three parts does a DHCP server need?
It needs an interface to serve, an address pool, and a network entry that gives the gateway and DNS server. The setup wizard builds all three.
What is a static lease and how do you create one from a dynamic lease?
A static lease ties a MAC address to one IP address. Run
/ip dhcp-server lease make-staticon the dynamic lease.Clients get an address but cannot reach the Internet, so what is missing?
The DHCP network entry probably lacks the gateway or DNS server. Without them clients can only reach the local subnet.
Topic 1 of 2 in DHCP
Test yourself on DHCP
The full MikroTik MTCNA question bank has 558 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by MikroTik. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.