Premium Only Content
Create your own DNS response time tool in Python
I can’t count the number of times I wish I had a tool that just …….
Many times, the tool exists, but part of a network management suite or solution which is not practical to install and configure for a simple test or the odd troubleshooting task.
In this video I will show you a small piece of code that I wrote to record DNS response time.
Here is the code below for you to simply cut and paste.
import csv
import datetime
import time
import dns.resolver
# DNS name to resolve
domain_name = "thetechfirm.com"
# Number of times to measure DNS response time
num_measurements = 100
counter = 0
delay = 1
print("Tonys DNS response time utility")
print("Performing name lookups for", domain_name, num_measurements, "times with a ", delay, "second delay")
# Create CSV file and write header row
with open('dns_response_times.csv', mode='w') as csv_file:
fieldnames = ['Date', 'Response Time (ms)']
writer = csv.DictWriter(csv_file, fieldnames=fieldnames)
writer.writeheader()
# Measure DNS response time multiple times and write results to CSV file
for i in range(num_measurements):
counter = counter+1
start_time = time.time()
# Perform DNS resolution
resolver = dns.resolver.Resolver()
resolver.nameservers = ['8.8.8.8'] # Google DNS server
answer = dns.resolver.resolve(domain_name)
end_time = time.time()
response_time_ms = (end_time - start_time) * 1000
# Write result to CSV file
writer.writerow({'Date': datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'Response Time (ms)': response_time_ms})
print("Testing", domain_name, "#", counter,response_time_ms,"ms")
time.sleep(delay)
-
1:04:57
Peter Schiff
5 hours agoPlan ₿ Forum El Salvador 2026 – Day 2
75.2K6 -
58:24
LFA TV
7 hours agoTHE CREST REPORT LIVE ON LFA | 1.31.26 @1PM EST
19.3K6 -
20:37
Simply Bitcoin
7 hours ago $1.82 earnedRod Roudi Interview at Plan B El Salvador 2026
14.5K -
4:03:01
LFA TV
18 hours agoRUMBLE RUNDOWN with JEREMY HERRELL SHAWN FARASH 1.31.25 9AM
122K21 -
8:23:28
FyrBorne
9 hours ago🔴The Division Live Gameplay: Wrapping Up NYC, then off to Washington DC
25.4K2 -
1:22:29
I_Came_With_Fire_Podcast
12 hours agoKratos Built the Navy’s Unbeatable Unmanned Aircraft
22.1K1 -
29:57
Simply Bitcoin
7 hours ago $2.88 earnedTone Vays Interview at Plan B El Salvador 2026
51.1K2 -
42:55
Simply Bitcoin
7 hours ago $4.03 earnedJack Mallers Interview at Plan B El Salvador 2026
58.9K1 -
22:21
Stephen Gardner
19 hours ago🚨Trump Tried To WARN US!
39.7K118 -
50:56
X22 Report
6 hours agoMr & Mrs X - D’s[DS] Are Trying To Stop The Midterms,Playbook Known, Trump Will Show The Way - EP 24
57.8K51