How to serve multiple search domains from Cisco IOS DHCP server?

Source - https://www.perkin.org.uk/

The expected

[code language="plain"]ip dhcp pool host.net.example.com
option 119 ascii net.example.com,example.com[/code]

doesn't work. So you need to encode search domains in hex using following example script written in Python:

[code language="python"]#!/usr/bin/env python
import syshexlist = []for domain in sys.argv[1:]:
for part in domain.split("."):
hexlist.append("%02x" % len(part))
for c in part:
hexlist.append(c.encode("hex"))
hexlist.append("00")print "".join([(".%s" % (x) if i and not i % 2 else x) \
for i, x in enumerate(hexlist)])[/code]

Execute it:

[code language="plain"]$ ./cisco.py net.example.com example.com
036e.6574.0765.7861.6d70.6c65.0363.6f6d.0007.6578.616d.706c.6503.636f.6d00[/code]

So the config in ios must look like:

[code language="plain"]ip dhcp pool host.net.example.com
option 119 hex 036e.6574.0765.7861.6d70.6c65.0363.6f6d.0007.6578.616d.706c.6503.636f.6d00[/code]

It's done!

Share with Me via Nextcloud