Ran into this problem recently too.
For anyone that comes across this, here's the solution, as it's not well-documented.
I'm using RouterOS v6.46.4.
To setup Option 160, do this:
/ip dhcp-server option add code=160 name="Captive Portal" value="'https://my.server.com/some/page'"
Note that the single quotes MUST be there. It's how Mikrotik knows it's a string.
This creates a DHCP Option, but it won't be used until you assign it to a DHCP server. To do that, you have a few options:
- Create a DHCP Option Set, add your Option to it, and add it to the DHCP Server; OR
- Create a DHCP Option Set, add your Option to it, and add it to the DHCP Network; OR
- Add the DHCP Option to the DHCP Network, without making an Option Set
All 3 should work in theory, but I only tested the last option.
At this point, it's setup, but there's a catch. If you have a device, like a Windows device, running Wireshark, and you do an "ipconfig /release" and "ipconfig /renew", your Wireshark will see some Options sent to you by the Mikrotik but you will NOT see Option 160. This is because:
According to the DHCP protocol, a parameter is returned to the DHCP client only if it requests this parameter, specifying the respective code in DHCP request Parameter-List (code 55) attribute. If the code is not included in Parameter-List attribute, the DHCP server will not send it to the DHCP client. --
https://wiki.mikrotik.com/wiki/Manual:I ... CP_Options
This is what tripped me up. Windows isn't requesting Option 160, so the Mikrotik won't send it. You need a device that explicitly requests Option 160 for the Mikrotik to send it.
If you want to test if the option is working, and you don't have a device that will request Option 160 handy, one thing you can do is this:
- Get the source code for dhcptest from https://github.com/CyberShadow/dhcptest
- Get and install DMD
- The tool is written in D (a programming language). You'll need the D compiler (DMD) to compile it
- During install of DMD, don't install Visual Studio, or anything extra when it asks. You don't need that.
- Compile the tool with: dmd dhcptest.d
- Run it with dhcptest --quiet --query --request 160 --print-only 160
This will request Option 160 from your DHCP server, and the Mikrotik will respond with that option. You should see it in Wireshark, and see the result printed by the tool.