DHCP Options
Sub-menu: /ip dhcp-server option
With help of DHCP Option list, it is possible to define additional custom options for DHCP Server to advertise. Option precedence is as follows:
radius,
lease,
server,
network.
This is the order in which client option request will be filled in.
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, DHCP server will not send it to the DHCP client.
Properties
Property | Description |
---|---|
code (integer:1..254; Default: ) | dhcp option code. All codes are available at http://www.iana.org/assignments/bootp-dhcp-parameters |
name (string; Default: ) | Descriptive name of the option |
value (string; Default: ) | Parameter's value.
RouterOS has predefined variables that can be used:
For example if HOSTNAME is 'kvm', then raw value will be 0x0176617264736b766d. |
raw-value (HEX string ) | Read only field which shows raw dhcp option value (the format actually sent out) |
Example
Classless Route
A classless route adds specified route in clients routing table. In our example, it will add
dst-address=160.0.0.0/24 gateway=10.1.101.1
dst-address=0.0.0.0/0 gateway=10.1.101.1
According to RFC 3442: The first part is the netmask ("18" = netmask /24). Second part is significant part of destination network ("A00000" = 160.0.0). Third part is IP address of gateway ("0A016501" = 10.1.101.1). Then There are parts of the default route, destination netmask (0x00 = 0.0.0.0/0) followed by default route (0x0A016501 = 10.1.101.1)
/ip dhcp-server option add code=121 name=classless value=0x18A000000A016501000A016501 /ip dhcp-server network set 0 dhcp-option=classless
Result:
[admin@MikroTik] /ip route> print Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit # DST-ADDRESS PREF-SRC GATEWAY DISTANCE 0 ADS 0.0.0.0/0 10.1.101.1 0 1 ADS 160.0.0.0/24 10.1.101.1 0
Much more robust way would be to use built in variables, previous example can be rewritten as:
/ip dhcp-server option add name=classless code=121 value="0x18A00000\$(NETWORK_GATEWAY)0x00\$(NETWORK_GATEWAY)"
Auto Proxy Config
/ip dhcp-server option add code=252 name=auto-proxy-config value="'http://autoconfig.something.lv/wpad.dat'"