18 December 2013

DHCP option 121

http://tools.ietf.org/html/rfc3442

This is used to add a classless static route to the DHCP clients.

To add option 121 to a Mikrotik DHCP server, it's value is specified in HEX. The format is as follows.

0xnnddddddddgggggggg

where n=mask, d=destination, g=gateway.

To convert ip address to HEX, you convert each octet, so 192=C0, 168=A8, 55=37, 1=01

You can use a tool such as http://www.miniwebtool.com/ip-address-to-hex-converter/?ip=192.168.55.1

Example:

To add a route to the destination network of 192.168.55.0/24 via gateway 172.16.10.1.

/ip dhcp-server option add name=classlessroutes code=121 value=0x18C0A837AC100A01

where 18 is 24 in hex.

*note: depending on the subnet mask, you may only need to specify 0-4 octets. In fact only the non-zero, or network portion of the subnet. Here is a table from the RFC.

             subnet mask           Number of octets
                     0                        0
                  1- 8                       1
                  9-16                      2
                 17-24                     3
                 25-32                     4

so for the /24 subnet in the above example, we only needed to specify 3 octets - C0A837

No comments:

Post a Comment