DHCP Client, Relay and Server · Topic 4 of 5
DHCP Options and Advanced Server Settings
Learn built in and custom DHCP options in RouterOS, option codes and value formats, option sets, and advanced server settings such as static only pools.
- 5 min
- Built in options are parameters in the DHCP network entry, such as
dns-serverandntp-server. - Custom options are defined with a name, a code and a value in
/ip dhcp-server option. - Text values use single quotes, and binary values use hexadecimal with a 0x prefix.
What it is
DHCP options are extra settings that the server sends to clients along with the address.
The address and lease time are only the start. Clients may also need a DNS server, a time server, a boot file or a vendor specific value. Each setting travels in an option, which has a number called its code, and a value.
RouterOS has built in parameters for the common options. For others, you define a custom option yourself.
How it works
Built in options are simple parameters, and custom options use a code and a value.
Built in options
The network entry already has parameters for the most used options. You set the value, and RouterOS sends it in the right option.
| Network parameter | Setting sent to the client |
|---|---|
| gateway | The default router |
| netmask | The subnet mask |
| dns-server | DNS servers |
| domain | The domain name |
| ntp-server | NTP servers |
| wins-server | WINS servers |
| next-server | The address of the boot server |
| boot-file-name | The file to boot from |
/ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1 ntp-server=192.168.88.1
The lease time is set on the server itself, not in the network entry. Use these parameters before you reach for a custom option, because they are easier to read and check.
Custom options
If a setting has no built in parameter, create an option with its code and value in /ip dhcp-server option.
/ip dhcp-server option add name=tftp-name code=66 value="'tftp.example.net'"
/ip dhcp-server option add name=ntp-hex code=42 value=0xC0A85801
The code is the option number from the DHCP standard. The value has a format that depends on its type.
| Value form | Example | Used for |
|---|---|---|
| Text in single quotes | 'tftp.example.net' | String options |
| Hexadecimal with 0x | 0xC0A85801 | Addresses and binary data |
The second example above is an NTP server option. The hexadecimal value is the address 192.168.88.1 written as four bytes. Every pair of hex digits is one part of the address.
When an option does not work, check the value format first. Text needs single quotes inside the double quotes, and addresses may need to be written as hexadecimal.
Using a custom option
A custom option does nothing until you attach it. Use the dhcp-option parameter on a network entry.
/ip dhcp-server network set 0 dhcp-option=tftp-name
Attached to a network entry, it applies to the clients of that subnet. You can also create an option set, which is a named group of options that you attach in one step with dhcp-option-set, on a network entry or on a server.
/ip dhcp-server option sets add name=voice-set options=tftp-name,ntp-hex
/ip dhcp-server network set 0 dhcp-option-set=voice-set
Option sets are a newer feature, so check that your RouterOS version supports them before you rely on them.
Advanced server settings
The server entry has settings beyond the basics.
| Setting | Effect |
|---|---|
| address-pool=static-only | Serve only clients that have a static lease |
| add-arp | Add an ARP entry for each lease |
| authoritative | Send NAK to clients that ask for an address the server does not know |
| always-broadcast | Send replies as broadcasts |
| lease-time | Default lease time for this server |
| use-radius | Take lease information from RADIUS |
| lease-script | Run a script when a lease is assigned or released |
With address-pool=static-only, the server gives nothing to unknown devices. Only the static leases you defined are served, which gives a basic form of access control on a LAN.
With add-arp, RouterOS adds an ARP entry for every lease. If you also set the interface to reply only to known ARP entries, clients that did not get a lease cannot talk to the router. This stops hosts that set their own static address.
/ip dhcp-server set dhcp1 address-pool=static-only add-arp=yes
Per lease settings
Individual leases can have extra settings, such as a different lease time, an address list for the client, or block-access to refuse a device. These help you give one device different treatment without a separate server.
Rogue server detection
A second DHCP server on the LAN can hand out wrong settings, by accident or on purpose. RouterOS has a DHCP alert feature that watches an interface and reports servers that it does not know.
What to remember for the exam
Eight facts cover most questions on this topic.
- Built in options are parameters in the DHCP network entry, such as
dns-serverandntp-server. - Custom options are defined with a name, a code and a value in
/ip dhcp-server option. - Text values use single quotes, and binary values use hexadecimal with a 0x prefix.
- A custom option must be attached, with
dhcp-optionor inside an option set, to take effect. - An option set groups options and is attached with
dhcp-option-set. address-pool=static-onlyserves only static leases.add-arpadds an ARP entry for each lease.- A DHCP alert can warn about rogue servers on an interface.
Options are looked up by code. A wrong code or format leads to a device that silently ignores the option.
Common mistakes
These four mistakes appear often.
Defining an option and not attaching it. The option is never sent until it is attached to a network entry or put in an option set that is attached.
Writing text without quotes. The value is then read in a different format.
Using a custom option when a built in parameter exists. Use dns-server and similar parameters first.
Expecting static only to secure the LAN alone. A client can still set its own address, unless you also use ARP controls.
Check yourself
Work through these three questions.
How do you send a setting that has no built in parameter?
Define a custom option with its code and value, then attach it with
dhcp-option.What does
address-pool=static-onlydo?The server serves only clients that have a static lease.
What does an option set do?
It groups several options so that you can attach them to a network or server in one step.
Topic 4 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.