Using EDNS0 is now optional and disabled by default
Also update documentation with new example
This commit is contained in:
parent
8535bb2aba
commit
40052f008d
26
README.md
26
README.md
@ -107,17 +107,21 @@ dnseval is a bulk ping utility that sends an arbitrary DNS query to a give list
|
||||
of DNS servers. This script is meant for comparing response time of multiple
|
||||
DNS servers at once:
|
||||
```
|
||||
% ./dnseval.py -f public-v4.txt -c3 ripe.net
|
||||
server avg(ms) min(ms) max(ms) stddev(ms) lost(%) flags
|
||||
----------------------------------------------------------------------------------
|
||||
8.8.8.8 210.225 109.864 407.420 170.785 %0 QR RD RA
|
||||
8.8.4.4 107.850 93.134 120.578 13.830 %0 QR RD RA
|
||||
ns.ripe.net 118.911 114.874 123.389 4.275 %0 QR AA RD
|
||||
4.2.2.1 104.380 102.449 106.588 2.083 %0 QR RD RA
|
||||
4.2.2.2 131.056 99.143 193.711 54.264 %0 QR RD RA
|
||||
4.2.2.3 98.956 97.463 100.310 1.429 %0 QR RD RA
|
||||
4.2.2.4 223.173 97.418 463.728 208.398 %0 QR RD RA
|
||||
4.2.2.5 104.290 97.264 117.878 11.770 %0 QR RD RA
|
||||
% ./dnseval.py -e -t AAAA -f public-v4.txt -c10 fg.weberdns.de
|
||||
server avg(ms) min(ms) max(ms) stddev(ms) lost(%) flags
|
||||
────────────────────────────────────────────────────────────────────────────────────────────────
|
||||
8.8.8.8 94.556 90.488 112.209 6.322 %0 QR -- -- RD RA AD --
|
||||
8.8.4.4 92.599 90.265 94.338 1.086 %0 QR -- -- RD RA AD --
|
||||
ns.ripe.net 92.754 91.632 93.980 0.900 %0 QR -- -- RD RA AD --
|
||||
4.2.2.1 92.703 91.869 93.298 0.482 %0 QR -- -- RD RA AD --
|
||||
4.2.2.2 93.195 91.667 94.919 1.065 %0 QR -- -- RD RA AD --
|
||||
4.2.2.3 93.118 92.076 94.835 0.835 %0 QR -- -- RD RA AD --
|
||||
4.2.2.4 94.308 92.175 103.318 3.261 %0 QR -- -- RD RA AD --
|
||||
4.2.2.5 92.650 91.643 94.460 1.002 %0 QR -- -- RD RA AD --
|
||||
209.244.0.3 92.810 89.961 94.807 1.266 %0 QR -- -- RD RA AD --
|
||||
209.244.0.4 93.127 91.962 95.970 1.227 %0 QR -- -- RD RA AD --
|
||||
195.46.39.39 92.770 90.777 93.656 0.914 %0 QR -- -- RD RA AD --
|
||||
195.46.39.40 92.903 91.280 94.914 1.147 %0 QR -- -- RD RA AD --
|
||||
```
|
||||
|
||||
### Author
|
||||
|
19
dnseval.py
19
dnseval.py
@ -54,6 +54,7 @@ usage: %s [-h] [-f server-list] [-c count] [-t type] [-w wait] hostname
|
||||
-w --wait maximum wait time for a reply (default: 5)
|
||||
-t --type DNS request record type (default: A)
|
||||
-T --tcp Use TCP instead of UDP
|
||||
-e --edns Use EDNS0
|
||||
""" % (__PROGNAME__, __VERSION__, __PROGNAME__))
|
||||
sys.exit()
|
||||
|
||||
@ -115,7 +116,7 @@ def flags_to_text(flags):
|
||||
return ' '.join(text_flags)
|
||||
|
||||
|
||||
def dnsping(host, server, dnsrecord, timeout, count, use_tcp=False):
|
||||
def dnsping(host, server, dnsrecord, timeout, count, use_tcp=False, use_edns=False):
|
||||
resolver = dns.resolver.Resolver()
|
||||
resolver.nameservers = [server]
|
||||
resolver.timeout = timeout
|
||||
@ -123,7 +124,8 @@ def dnsping(host, server, dnsrecord, timeout, count, use_tcp=False):
|
||||
resolver.retry_servfail = 0
|
||||
flags = 0
|
||||
answers = None
|
||||
resolver.use_edns(edns=0, payload=4096, ednsflags=dns.flags.edns_from_text('DO'))
|
||||
if use_edns:
|
||||
resolver.use_edns(edns=0, payload=8192, ednsflags=dns.flags.edns_from_text('DO'))
|
||||
|
||||
response_times = []
|
||||
i = 0
|
||||
@ -133,7 +135,8 @@ def dnsping(host, server, dnsrecord, timeout, count, use_tcp=False):
|
||||
break
|
||||
try:
|
||||
stime = time.time()
|
||||
answers = resolver.query(host, dnsrecord, tcp=use_tcp, raise_on_no_answer=False) # todo: response validation in future
|
||||
answers = resolver.query(host, dnsrecord, tcp=use_tcp,
|
||||
raise_on_no_answer=False) # todo: response validation in future
|
||||
etime = time.time()
|
||||
except (dns.resolver.NoNameservers, dns.resolver.NoAnswer):
|
||||
break
|
||||
@ -184,11 +187,12 @@ def main():
|
||||
inputfilename = None
|
||||
fromfile = False
|
||||
use_tcp = False
|
||||
use_edns = False
|
||||
hostname = 'wikipedia.org'
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hf:c:t:w:T",
|
||||
["help", "file=", "count=", "type=", "wait=", "tcp"])
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hf:c:t:w:Te",
|
||||
["help", "file=", "count=", "type=", "wait=", "tcp", "edns"])
|
||||
except getopt.GetoptError as err:
|
||||
print(err)
|
||||
usage()
|
||||
@ -212,6 +216,8 @@ def main():
|
||||
dnsrecord = a
|
||||
elif o in ("-T", "--tcp"):
|
||||
use_tcp = True
|
||||
elif o in ("-e", "--edns"):
|
||||
use_edns = True
|
||||
else:
|
||||
print("Invalid option: %s" % o)
|
||||
usage()
|
||||
@ -251,7 +257,8 @@ def main():
|
||||
if not s:
|
||||
continue
|
||||
(s, r_avg, r_min, r_max, r_stddev, r_lost_percent, flags) = dnsping(hostname, s, dnsrecord, waittime,
|
||||
count, use_tcp=use_tcp)
|
||||
count, use_tcp=use_tcp,
|
||||
use_edns=use_edns)
|
||||
|
||||
s = server.ljust(width + 1)
|
||||
text_flags = flags_to_text(flags)
|
||||
|
@ -0,0 +1 @@
|
||||
dnspython==1.15.0
|
Loading…
x
Reference in New Issue
Block a user