Skip to content

Instantly share code, notes, and snippets.

@muink
Forked from alxrdn/dnsmasq_https_rr.py
Created September 24, 2025 14:39
Show Gist options
  • Select an option

  • Save muink/efe75dd136c837da53424dc282f7d81b to your computer and use it in GitHub Desktop.

Select an option

Save muink/efe75dd136c837da53424dc282f7d81b to your computer and use it in GitHub Desktop.
Generate dnsmasq configuration for HTTPS resource records (RFC 9460)
import dns.rdata # pip3 install dnspython
import io
name = "host.example.com."
rclass = dns.rdataclass.IN
rtype = dns.rdatatype.HTTPS
rdata = '1 . alpn="h3,h2" ipv4hint="XXX.XXX.XXX.XXX"'
rd = dns.rdata.from_text(rclass, rtype, rdata)
f = io.BytesIO()
rd.to_wire(f)
wire_data = f.getvalue()
print ("dnsmasq option: --dns-rr=" + name + "," + str(rtype) + "," + wire_data.hex().upper())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment