Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Created July 20, 2023 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WietseWind/8c5d3833d0ef4764d74c10c58383dbf5 to your computer and use it in GitHub Desktop.
Save WietseWind/8c5d3833d0ef4764d74c10c58383dbf5 to your computer and use it in GitHub Desktop.
Get IPv6 client DUID from EdgeOS dhcpv6 Lease
  1. Find client: cat /run/dhcpdv6.leases
  2. Get ia-na value.

If not starting with \000\000\000, slicing required.

Python script to turn DUID into needed format:

import binascii

# Replace the string below with your IA_NA data
ia_na_data = "\000\002\000\..."

# Convert the binary data to a hexadecimal string
hex_duid = binascii.hexlify(ia_na_data)

print(hex_duid)

Python script to slice IAID from DUID and convert to DUID format:

import binascii

# Replace the string below with your IA_NA data
ia_na_data = b"\266\"\017\353\000\002\000\..."

# Convert the binary data to a hexadecimal string
hex_data = binascii.hexlify(ia_na_data)

# IAID is the first 4 bytes (8 hex characters)
iaid = hex_data[:8]
# DUID is the rest
duid = hex_data[8:]

print("IAID:", iaid.decode())
print("DUID:", duid.decode())

Then, to create a static mapping:

set service dhcpv6-server shared-network-name SOMENAME subnet 2a0c:xxxx::/64 static-mapping SOMETHING identifier 00:02:00...
set service dhcpv6-server shared-network-name SOMENAME subnet 2a0c:xxxx::/64 static-mapping SOMETHING ipv6-address 2a0c:xxx::...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment