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
Drew Hernandez
6 hours agoLEFTISTS UNITE TO DEFEND KIMMEL & ANTIFA TO BE DESIGNATED TERRORISTS BY TRUMP
756 watching -
1:12:32
The Charlie Kirk Show
2 hours agoTPUSA AT CSU CANDLELIGHT VIGIL
40.1K29 -
LIVE
Akademiks
4 hours agoCardi B is Pregnant! WERE IS WHAM????? Charlie Kirk fallout. Bro did D4VID MURK A 16 YR OLD GIRL?
1,282 watching -
Barry Cunningham
3 hours agoPRESIDENT TRUMP HAS 2 INTERVIEWS | AND MORE PROOF THE GAME HAS CHANGED!
44.9K23 -
1:20:27
Glenn Greenwald
4 hours agoLee Fang Answers Your Questions on Charlie Kirk Assassination Fallout; Hate Speech Crackdowns, and More; Plus: "Why Superhuman AI Would Kill Us All" With Author Nate Soares | SYSTEM UPDATE #518
49.4K22 -
1:03:06
BonginoReport
5 hours agoLyin’ Jimmy Kimmel Faces The Music - Nightly Scroll w/ Hayley Caronia (Ep.137)
99.8K48 -
55:40
Donald Trump Jr.
8 hours agoThe Warrior Ethos & America's Mission, Interview with Harpoon Ventures Founder Larsen Jensen | Triggered Ep275
49.7K52 -
1:12:08
TheCrucible
4 hours agoThe Extravaganza! EP: 39 (9/18/25)
112K14 -
1:21:41
Kim Iversen
6 hours agoNick Fuentes Denies Israel Killed Charlie Kirk | Right-Wing CANCELS Jimmy Kimmel
44.3K209 -
1:01:59
Candace Show Podcast
4 hours agoEXCLUSIVE! Another Photo Of Tyler Robinson | Candace Ep 238
100K335