Premium Only Content
![Create your own DNS response time tool in Python](https://1a-1791.com/video/s8/1/2/B/o/h/2Bohj.qR4e-small-Create-your-own-DNS-respons.jpg)
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)
-
9:41
Gun Owners Of America
1 day agoATF Is Using Facial Recognition AI To Track Gun Owners
20.1K10 -
16:01
Clownfish TV
10 hours agoDisney Officially ENDS Reimagine Tomorrow DEI Program?!
12.2K4 -
23:11
ArturRehi
1 day agoThe Truth about U.S. Aid to Russia
10.9K -
1:43:13
MTNTOUGH Fitness Lab
18 hours agoMental Strength VS Physical Strength: What Elite Hunters Really Need (w/Remi Warren)
9.37K2 -
2:27
BIG NEM
12 hours agoBalkan Trauma Explained to Africans: The Hidden Truth About Identity & History
24.3K3 -
12:06
John Crump News
22 hours ago $0.73 earnedTwo Cases That Should Be Examined Under President Trump's Executive Order
19.5K3 -
1:00:33
Trumpet Daily
20 hours ago $4.44 earnedThe Final Coup Attempt - Trumpet Daily | Feb. 11, 2025
16.9K25 -
2:56:59
TimcastIRL
12 hours agoTrump Border Czar Hints He'll ARREST Leftists Aiding Illegal Immigrants w/Mark Dubowitz | Timcast IRL
249K263 -
41:14
The White House
10 hours agoPresident Trump Greets and Welcomes Marc Fogel Back to The United States
123K72 -
6:48:41
Akademiks
12 hours agoKendrick Lamar performs at the Superbowl. Does NOT LIKE US. Now projected to sell 230K! Drake done?
161K16