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
Kim Iversen
1 hour agoWas There a Second Shooter in the Charlie Kirk Attack?
2,246 watching -
LIVE
Redacted News
2 hours ago“They’re NOT stopping with Charlie Kirk!” JD Vance TORCHES violent leftists | Redacted
10,152 watching -
39:45
Kimberly Guilfoyle
1 hour agoCharlie's Legacy and Our Mission | Ep.253
12.3K8 -
UPCOMING
Tundra Tactical
1 hour agoWhats The Deal With New Guns In 2025 Part 2
81 -
UPCOMING
The Amber May Show
3 hours agoCharlie Kirk Murder Probe EXPLODES | FBI, FEMA, & SCOTUS Shake the Nation
931 -
1:14:55
vivafrei
5 hours agoJD Vance Pays Tribute to Charlie Kirk; Ryan Routh Trial Continues! And More!
168K91 -
LIVE
Dr Disrespect
6 hours ago🔴LIVE - DR DISRESPECT - WARZONE - PROTECT THE DOC
1,153 watching -
LIVE
LFA TV
19 hours agoLFA TV ALL DAY STREAM - MONDAY 9/15/25
1,540 watching -
29:05
Athlete & Artist Show
5 hours ago1st Line Minutes at 35, Slovenian Sports Fans, and MORE
4.61K -
LIVE
freecastle
5 hours agoTAKE UP YOUR CROSS- Our Battles, HE Has Already Won!
176 watching