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)
-
LIVE
The Charlie Kirk Show
1 hour agoWe Don’t Have To Live This Way + The Death of Britain | Emmons, Shirley, Prof. Orr | 9.10.2025
2,292 watching -
LIVE
Steven Crowder
3 hours ago🔴Iryna Zarutska Was Failed - And We Won't Forget Who Did It
24,058 watching -
LIVE
Rebel News
25 minutes agoLibs 'monitoring' trans law, Quebec tax hoarding, Ford says 'look harder' | Buffalo Roundtable
83 watching -
LIVE
Badlands Media
54 minutes agoThe Daily Herold: Sept. 10, 2025
234 watching -
1:06:13
The Rubin Report
2 hours agoPress Gasps When Told Trump’s Brutal Plan for Charlotte Stabbing Suspect
20.6K36 -
LIVE
The Mel K Show
1 hour agoMORNINGS WITH MEL K - Preparing for the Truth Tsunami: Can We Handle the Truth? 9-10-25
879 watching -
1:35:20
Benny Johnson
3 hours agoBlack on White Crime Epidemic EXPOSED After Charlotte Murder | Trump Calls for 'DEATH PENALTY'
34.3K108 -
DVR
Bannons War Room
6 months agoWarRoom Live
35.1M8.23K -
LIVE
The Shannon Joy Show
4 hours agoThe Truth Is Coming Out About Vaccine Death. Ron Johnson’s Bombshell Hearing & Courtaney Turner!
317 watching -
1:00:35
VINCE
4 hours agoBiden Jobs Reports Were Found Fake, AGAIN | Episode 122 - 09/10/25
165K254