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
RealAmericasVoice
3 days agoHOME OF REAL NEWS
6,489 watching -
2:04:21
Badlands Media
17 hours agoDevolution Power Hour Ep. 388: Assassination, Inflection Points, and the Battle Ahead
352K117 -
2:08:03
Inverted World Live
10 hours agoCharlie Kirk Assassinated | Ep. 106
124K60 -
3:01:07
TimcastIRL
12 hours agoCharlie Kirk Assassinated, Suspect In Custody | Timcast IRL
671K1.1K -
5:44:49
Redacted News
14 hours agoTurning the Tide: 9/11 Justice in 2025 — Day 1 with Sen. Ron Johnson, Richard Gage and More
204K89 -
2:48:00
TheSaltyCracker
12 hours agoYou're Being Hunted ReeEEStream 9-10-25
326K672 -
13:09:56
LFA TV
1 day agoBREAKING: CHARLIE KIRK ASSASSINATED - WEDNESDAY 9/10/25
405K133 -
1:31:08
I_Came_With_Fire_Podcast
12 hours agoCheck Fire: God Bless Charlie Kirk
115K32 -
1:13:35
Glenn Greenwald
14 hours agoCharlie Kirk Assassinated; NATO Alleges Russian Drones Flew Over Poland, and More | SYSTEM UPDATE #512
312K346 -
1:46:28
Badlands Media
1 day agoAltered State S3 Ep. 45: The Assassination of Charlie Kirk
183K33