1. Home
  2. Developer tools
  3. DHCP Option Encoder

DHCP Option Encoder

DHCP options 121 and 43 are hard to write by hand. List your routes or controller addresses and get the exact hex plus lines for ISC dhcpd, dnsmasq and Cisco.

Free, no sign-up. Runs in your browser: nothing is uploaded.

How to use DHCP Option Encoder

  1. Choose routes or vendor-specific options.
  2. Enter your data.
  3. Copy the hex and configuration lines.

Features

  • Option 121 per RFC 3442 (also used as 249)
  • Option 43 sub-options, with a Cisco controller helper (241)
  • Hex decoder for both
  • Lines for ISC dhcpd, dnsmasq and Cisco IOS
  • Checks prefixes and host bits
  • Shows what a client will install

Supported formats

Input

  • Routes, strings or addresses

You get

  • Option 121 and 43 hex bytes

Private by design

Everything you enter is processed by your browser on this device. Nothing is sent to openWorkstand or anyone else, so the DHCP Option Encoder is safe for private and work data. After you have used it once while online, it also works without an internet connection. How local processing works

Good to know

  • Options 121 and 43 are covered; other options are not.
  • Option 43 contents are vendor-specific, so the tool only encodes generic sub-options.

Guide

Encoding DHCP option 121 routes and option 43 vendor data

A DHCP server gives out more than an address. It can also tell clients about static routes, for example “reach the 192.168.50.0/24 network through this router”, which saves configuring each machine. The format of that option is compact and awkward to write by hand. The page encodes a list of routes into option 121 and shows the lines for common DHCP servers.

How option 121 is built

Each route is encoded as a sequence of bytes. The first byte is the prefix length, from 0 to 32. Then come only the octets of the destination that the prefix covers, rounded up to whole bytes. Then four bytes give the router address. So 192.168.50.0/24 via 10.0.0.1 is the prefix length 24 (18 in hex), three destination octets (c0 a8 32) and the router (0a 00 00 01): 18:c0:a8:32:0a:00:00:01. Routes are simply concatenated. A default route is the prefix length 0, no destination bytes and the router. The standard is RFC 3442.

Entering routes

Type one route per line in the form network/prefix via router, or press Sample. The page validates each line and then prints the option as a colon-separated hex string with its length, followed by configuration lines. For ISC dhcpd it writes option rfc3442-classless-static-routes with decimal values separated by commas; for dnsmasq, a dhcp-option=121,... line with the routes in readable form; and for Cisco IOS and Windows Server a raw hex line. A panel “What a client will install” repeats the routes so you can check what was understood.

Option 43 and decoding

The second tab handles vendor-specific information (option 43). It carries a series of sub-options, each with a code, a length and a value, whose meaning depends on the device vendor; Cisco lightweight access points, for example, look for sub-option 241 containing their controllers’ IPv4 addresses. The third tab decodes a hex string back into routes, which is useful when a capture shows option 121 and you want to know what it does.

Windows and option 249

Windows clients historically use option 249 for classless static routes, while other systems use 121. If you serve both, configure both options with the same data. As the page notes, a client that gets option 121 ignores option 3, the router option, so the default gateway must be part of option 121 as a 0.0.0.0/0 route. Forgetting that leaves the client without a default route, one of the most common problems with this option.

A worked example

The sample has three routes: 192.168.50.0/24 via 10.0.0.1, 10.99.0.0/16 via 10.0.0.254 and 0.0.0.0/0 via 10.0.0.1. The page encodes them as 18:c0:a8:32:0a:00:00:01:10:0a:63:0a:00:00:fe:00:0a:00:00:01, 20 bytes. The dnsmasq line is dhcp-option=121,192.168.50.0/24,10.0.0.1,10.99.0.0/16,10.0.0.254,0.0.0.0/0,10.0.0.1, and the raw line is option 121 hex 18c0a8320a000001100a630a0000fe000a000001. Note that the /16 route has only two destination octets (0a 63).

Limits

Only options 121 and 43 are covered, and the option 43 sub-options are generic because their meaning depends on the vendor. Syntax differs between DHCP servers and versions, so test the generated line on one client first. The total option length is limited to 255 bytes, so a very long route list may need splitting across servers or a different approach.

Checked against the current version of the DHCP Option Encoder on .

Frequently asked questions

Why does a client ignore the default gateway option when option 121 is present?

RFC 3442 says that if option 121 is sent, the client must ignore option 3. A default route therefore has to be included in option 121 itself as 0.0.0.0/0 via the gateway, as the page does in its sample.

How many octets of the destination are written?

Only as many as the prefix needs: none for /0, one for /1 to /8, two for /9 to /16, three for /17 to /24 and four above that. This is why a /24 route takes only three destination bytes.

How is 192.168.50.0/24 via 10.0.0.1 encoded in option 121?

18 c0 a8 32 0a 00 00 01: the prefix length 24 (0x18), the three significant octets of the network, and the four bytes of the router.

Does a default route in option 121 replace option 3?

Yes. A client that receives option 121 ignores the router option 3, so include a default route (0.0.0.0/0) in option 121 when you use it.

Keep working with the result

openWorkstand also includes a free workspace with documents, spreadsheets, tasks, projects and a calendar that save to a folder on your computer.