Skip to content

Instantly share code, notes, and snippets.

@SweBarre
Last active March 13, 2024 16:04
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SweBarre/0f3b984fd655601d4f13e6af065fde77 to your computer and use it in GitHub Desktop.
Save SweBarre/0f3b984fd655601d4f13e6af065fde77 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# Domain Search Option Format generator for Unifi Security Gateway
# Usage: python3 dhcp_option_119.py example.com example.net
import sys
hexes = []
for domain in sys.argv[1:]:
for label in domain.split('.'):
hexes.append('%02x' % len(label))
hexes.extend(['%02x' % ord(char) for char in str.lower(label)])
hexes.append('00')
print(":".join(hexes))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment