DHCP Client, Relay and Server · Topic 3 of 5
DHCP Server Networks and Pools
Learn how to build a RouterOS DHCP server: the IP pool, the network entry with gateway and DNS, the server, lease time, and dynamic and static leases.
- 5 min
- A DHCP server needs a pool, a network entry and a server entry.
- Pools are in
/ip pool, networks in/ip dhcp-server network, servers in/ip dhcp-server. - The network entry gives the gateway, DNS servers and domain to clients.
What it is
A DHCP server hands out addresses and network settings to clients on an interface.
Three parts work together in RouterOS. The IP pool holds the addresses to give out.
The DHCP network holds the settings that go with them, such as the gateway. The DHCP server ties them to an interface.
If any of the three is missing, clients get nothing.
How it works
You create the pool, the network and then the server.
Step one: the IP pool
A pool is a named list of address ranges in /ip pool.
/ip pool add name=lan-pool ranges=192.168.88.100-192.168.88.200
You can give more than one range, separated by commas. Keep the router address and any fixed servers out of the range. The pool menu is also used by other services, such as PPP, so one pool can be shared where it makes sense.
Step two: the DHCP network
The network entry describes the subnet and the settings handed out with it. It lives in /ip dhcp-server network.
/ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1 domain=lan.example
| Parameter | What the client receives |
|---|---|
| address | The subnet this entry applies to, which also gives the mask |
| gateway | The default gateway |
| dns-server | One or more DNS servers |
| domain | The domain name |
| ntp-server | An NTP server |
| wins-server | A WINS server |
The server finds the right network entry by comparing the client subnet with the entries. If the subnet does not match, the clients receive no usable settings.
Step three: the DHCP server
The server entry binds a pool to an interface in /ip dhcp-server.
/ip dhcp-server add name=dhcp1 interface=bridge address-pool=lan-pool lease-time=1d disabled=no
The interface must have an IP address in the same subnet as the pool. The server uses that address as its own identity on the network.
| Parameter | Meaning |
|---|---|
| interface | Where the server listens |
| address-pool | The pool to take addresses from |
| lease-time | How long a lease lasts |
| disabled | A server is created disabled until you set no |
In many cases the setup command does all three steps for you, and asks for the pool, the gateway and the DNS servers.
/ip dhcp-server setup
Leases
A lease is the binding between a client and an address. The leases are in /ip dhcp-server lease.
| Type | How it is made |
|---|---|
| Dynamic | The server picks an address from the pool and the lease ends when the time runs out |
| Static | You tie a MAC address to a fixed address, so the client always gets the same one |
/ip dhcp-server lease add address=192.168.88.50 mac-address=00:0C:42:AA:BB:CC server=dhcp1
/ip dhcp-server lease make-static 0
A static lease keeps a printer or a camera at a known address while still using DHCP. The make-static command turns an existing dynamic lease into a static one. Static leases may use addresses outside the pool range, as long as they are in the same subnet.
What the server checks
Before it offers an address, the server checks that nobody uses it. This avoids a duplicate address on the network. A lease shows a status such as bound when active, and offered when the address is proposed but not yet confirmed.
If the pool is exhausted, new clients get no address. You can see the used and free addresses with /ip pool used print. Raise the pool size, or lower the lease time, when many short visits fill it.
A shorter lease time helps when many guests come and go, because addresses return to the pool faster.
Common troubleshooting steps
When clients do not get an address, check these points in order.
- The server is enabled and bound to the correct interface.
- The interface has an address in the pool subnet.
- The pool has free addresses.
- A network entry covers the subnet.
- No firewall rule drops DHCP traffic.
What to remember for the exam
Eight facts cover most questions on this topic.
- A DHCP server needs a pool, a network entry and a server entry.
- Pools are in
/ip pool, networks in/ip dhcp-server network, servers in/ip dhcp-server. - The network entry gives the gateway, DNS servers and domain to clients.
- The interface needs an address in the same subnet as the pool.
lease-timesets how long a lease lasts.- Dynamic leases come from the pool, and static leases tie a MAC address to an address.
make-staticconverts a dynamic lease into a static one./ip dhcp-server setupcreates the pool, network and server together.
A server created by hand starts disabled. Check the status after you add it.
Common mistakes
These four mistakes appear often.
Forgetting the network entry. Clients get an address but no gateway or DNS.
Using a pool outside the interface subnet. The server cannot serve that pool on the interface.
Including the router address in the pool. The pool may give out the router address to a client.
Leaving the server disabled. A new entry does nothing until it is enabled.
Check yourself
Work through these three questions.
Which three items does a basic DHCP server need?
An IP pool, a DHCP network entry and a DHCP server entry.
Where does the gateway given to clients come from?
From the
gatewayparameter in the DHCP network entry.How do you keep a device on the same address with DHCP?
Create a static lease that ties its MAC address to the address.
Topic 3 of 5 in DHCP Client, Relay and Server
Test yourself on DHCP Client, Relay and Server
The full MikroTik MTCTCE question bank has 479 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.