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
SynthTrax & DJ Cheezus Livestreams
12 hours agoFriday Night Synthwave 80s 90s Electronica and more DJ MIX Livestream Knight Ride Edition
180 watching -
2:31:18
Laura Loomer
3 hours agoEP134: EXPOSED: Microsoft Allowed China Access To DOD Cyber Systems
122K40 -
LIVE
FusedAegisTV
5 hours agoRumble Smackdown! #004 Tekken 8 $100+ Online Tournament !bracket !prizepool
82 watching -
The Mike Schwartz Show
8 hours agoTHE MIKE SCHWARTZ SHOW Evening Edition 07-18-2025 with guest Congressman Buddy Carter!
18.6K6 -
LIVE
DopeFrags
6 hours agoOne of the best survival games ever? | Grounded
21 watching -
1:03:43
Sarah Westall
2 hours agoPlanning is Over, War has Started: First Stage of Economic Global War: Commodities w/ Andy Schectman
12.1K -
LIVE
Fragniac
2 hours ago( -_•)╦ ╤─💥 MAKING GAMING GREAT AGAIN w/ The @BrrrapPack 🎮❗
16 watching -
58:41
BonginoReport
9 hours agoTrump Impersonations & Friday Fun w/ Shawn Farash - Nightly Scroll w/ Hayley Caronia (Ep.93)
79.1K20 -
LIVE
BSparksGaming
11 hours agoDonkey Kong BONANZA Walkthrough Gameplay! (Part 2)
93 watching -
12:26:08
LFA TV
22 hours agoLFA TV ALL DAY STREAM - FRIDAY 7/18/25
174K25