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
LFA TV
15 hours agoLIVE & BREAKING NEWS! | TUESDAY 10/28/25
3,110 watching -
LIVE
The Mel K Show
1 hour agoMORNINGS WITH MEL K -Restoring National Sovereignty After Decades of Global Deception - 10-28-25
675 watching -
LIVE
The Shannon Joy Show
1 hour agoSJ Show 10/28 - Idiocracy 2025! Are Candace Owens & Nick Fuentes Government Agent Provocateurs? Because The Political Soap Opera Is Getting Kinda Stupid
179 watching -
LIVE
Grant Stinchfield
59 minutes agoBillions for Nothing: New Study Reveals Widespread Fraud and Ghost Enrollments in Obamacare
177 watching -
1:00:58
VINCE
3 hours agoBiden Is Back: "Democracy Is At Stake" (w/ Michael Knowles)| Episode 156 - 10/28/25
136K111 -
LIVE
Dr Disrespect
3 hours ago🔴LIVE - DR DISRESPECT - BATTLEFIELD 6 - REDSEC LAUNCH - BATTLE ROYALE
1,697 watching -
1:27:53
Graham Allen
4 hours agoINSANE Libs Are Dressing As Dead Charlie For Halloween… + His Killer Getting Special Treatment??
102K53 -
2:00:58
Badlands Media
9 hours agoBadlands Daily: October 28, 2025
29K13 -
51:06
House Republicans
2 hours agoHouse Republicans Leadership Stakeout
6.57K1 -
1:15:01
Benny Johnson
2 hours ago🚨New Biden BOMBSHELL Criminal Evidence Released LIVE Right Now | All Pardons 'Void' | DOJ Ready...
19.1K26