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

Source –

The expected

[code language=“plain“]ip dhcp pool
option 119 ascii,[/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(„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“]$ ./

So the config in ios must look like:

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

It’s done!

This site uses Akismet to reduce spam. Learn how your comment data is processed.