Dhcp Option 43 for Aironet Aps

Just a quick hacky script to generate dhcp option 43 for Cisco LAPs to join Wireless Lan Controllers (WLC). This script outputs a line to add to your dhcpd.conf subnet declaration. It takes a list of IPs as arguments and will convert them into a suitable dhcpd.conf entry.

Script invocation example:

[email protected]:~$ ./gen-dhcp-43.py 192.168.10.5 192.168.10.20
Please add the following line to the correct subject declaration.
option vendor-encapsulated-options f1:08:c0:a8:0a:05:c0:a8:0a:14;

Example subnet declaration

   subnet 192.168.10.0 netmask 255.255.255.0 {
       range dynamic-bootp 192.168.10.0 192.168.10.255;
       option broadcast-address 192.168.10.255;
       option routers 192.168.10.1;
       option vendor-encapsulated-options f1:08:c0:a8:0a:05:c0:a8:0a:14;
       max-lease-time 604800;
       default-lease-time 604800;
       host hostname {
         hardware ethernet xx:xx:xx:xx:xx:xx;
         fixed-address 192.168.10.10;
       }
   }                                                                                                    

Script

#!/usr/bin/env python3
#
# Configure Cisco LAPs to join WLC via dhcpd option 43.
# 11/16/2021 [email protected]

import sys

if len(sys.argv) < 1:
    print(f"Usage: {sys.argv[0]} <ip1> <ip2> <...>")
    exit(1)

def gen_hex(ip):
    ipsplit = ip.split('.')
    hexxed = ':'.join(hex(int(i))[2:].zfill(2) for i in ipsplit)
    return(hexxed)

def gen_prefix(num):
    type = "f1"
    length = hex(int(num * 4))[2:].zfill(2)
    return(f"{type}:{length}")

num_ips = len(sys.argv) - 1

prefix = gen_prefix(num_ips)

hexips = []
for ip in sys.argv[1:]:
    iphex = gen_hex(ip)
    hexips.append(iphex)

hexips = ':'.join(hexips)

print("Please add the following line to the correct subject declaration.")
print(f"option vendor-encapsulated-options {prefix}:{hexips};")

Illustration of Vince

Vince Hillier is the President and Founder of Revenni Inc. He is an opensource advocate specializing in system engineering and infrastructure. Outside of building solid architecture that doesn't break the bank, he's interested in information security, privacy, and performance.