examples/ecs.py
raw| 1 | #!/usr/bin/env python3 |
| 2 | import dns.edns |
| 3 | import dns.message |
| 4 | import dns.query |
| 5 | |
| 6 | # This example demonstrates how to use the EDNS client subnet option |
| 7 | |
| 8 | ADDRESS = "0.0.0.0" # replace this with the address you want to check |
| 9 | PREFIX = 0 # replace this with a prefix length (typically 24 for IPv4) |
| 10 | |
| 11 | ecs = dns.edns.ECSOption(ADDRESS, PREFIX) |
| 12 | q = dns.message.make_query("www.google.com", "A", use_edns=0, options=[ecs]) |
| 13 | r = dns.query.udp(q, "8.8.8.8") |
| 14 | print(r) |