Domain Search List option in DHCP (code 119), must follow RFC3397 requirements to work. Check out RFC example, which sums it up pretty well. Here is a short list of these requirements:

  • Domain name is split by dots into individual parts
  • Each domain part is prefixed with its length
  • Each domain name is separated by NUL octet
  • Each following domain name must use DNS domain name compression

Here are some examples for implementation in RouterOS:

One domain in search list

Domain used:


/ip dhcp-server option add name=domain-search-list code=119 value="0x07'onlyone'0x07'example'0x03'net'0x00"

Two domains in search list

Domains used:,


/ip dhcp-server option add name=domain-search-list code=119 value="0x05'first'0x07'example'0x03'net'0x0006'second'0xc006"

The most tricky part in this example is compression usage for the second domain in the list. It is represented by the last 2 octets (0xc006):

  • Octet c0 represents 2 left-most bits set to 1. It is a flag for compression pointer.
  • Octet 06 represents the pointer itself. It points to the 6th byte of our DHCP option value. This is where length byte of example domain part starts.

Mentioned command adds DHCP option to the list of options for DHCP server. Each option then can be assigned to DHCP network and server will provide it to clients.


John Simpson · July 31, 2016 at 20:13

Thank you for the examples of how to do the DNS encoding. This page saved me at least half an hour of trial-and-error before I would have gone digging through the RFCs. 🙂

Also, I wrote a Perl script which calculates the raw values for you. You and your readers might find it useful.

    Pessoft · August 11, 2016 at 22:47

    I’m glad, the information is helpful. Also thank you for your script 😉

دامنه · November 1, 2016 at 06:31

many thanks for info

xiaofang · August 12, 2018 at 09:29

I am from china , thanks very much!!

luckyelms · August 29, 2019 at 20:15

Been led here by google. I dont know if what am looking at is the right one. What am trying to accomplish is to able to ping my hosts on the LAN by their names eg ping d-716 and i get a reply like i’ve pinged its IP address.
So far i’ve failed and the articles am reading arent addressing the problem properly. I guess its meant for experts.

    Pessoft · September 1, 2019 at 02:28

    Hi, this article is about a different topic. You should be able to ping LAN host names if you will add them to Mikrotik DNS static names. Either manually ( for example like /ip dns static add address= name=myhost ) or automatically ( for example using DHCP lease script ). If you want to discuss it further, send me more info via some contact in About section.

eggbean · September 29, 2020 at 23:53

I have read elsewhere that the string needs to be terminated with a null byte (0x00).

    Pessoft · October 1, 2020 at 20:17

    Thanks, I’ve fixed it in DHCP option value example.

Comments are closed.