[GH-ISSUE #220] Feature Request: DNS Response Check #2082

Closed
opened 2026-03-14 02:24:05 +03:00 by kerem · 7 comments
Owner

Originally created by @johnnyq on GitHub (Dec 21, 2020).
Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/220

Add a check to check for DNS response time based on the current configured resolver and report if response is slow or name doesn't resolve this could help troubleshoot slow website loading if a DNS server is the issue. have the domain it checks configurable.

Originally created by @johnnyq on GitHub (Dec 21, 2020). Original GitHub issue: https://github.com/amidaware/tacticalrmm/issues/220 Add a check to check for DNS response time based on the current configured resolver and report if response is slow or name doesn't resolve this could help troubleshoot slow website loading if a DNS server is the issue. have the domain it checks configurable.
kerem closed this issue 2026-03-14 02:24:10 +03:00
Author
Owner

@dinger1986 commented on GitHub (Dec 21, 2020):

I'm sure PowerShell would do this for you.

So you want it to show it it's longer than x time to resolve a dns query and to fail if it doesn't resolve the query? Is that right?

This is probably a script which could be written. Probably best discussing on discord.

<!-- gh-comment-id:749244096 --> @dinger1986 commented on GitHub (Dec 21, 2020): I'm sure PowerShell would do this for you. So you want it to show it it's longer than x time to resolve a dns query and to fail if it doesn't resolve the query? Is that right? This is probably a script which could be written. Probably best discussing on discord.
Author
Owner

@johnnyq commented on GitHub (Dec 22, 2020):

@dinger1986 exactly this

<!-- gh-comment-id:749284613 --> @johnnyq commented on GitHub (Dec 22, 2020): @dinger1986 exactly this
Author
Owner

@dinger1986 commented on GitHub (Dec 23, 2020):

I have written one for powershell, does this suit your needs?

Just upload to tactical scripts and change $hostname and $time

Does a ping, checks it can resolve and then times the lookup.

## name of hostname to run DNS checks against please leave the name in brackets
$hostname = 'bbc.com'

## allowed time for DNS check to be done (Milliseconds)
$time = 100

write-host -NoNewLine "Verifying" $hostname " ... "

## Do a ping test to ensure hostname can be contacted

if (Test-Connection $hostname -Count 1 -ErrorAction SilentlyContinue) 
	{ 
	write-host "Ping test passed for $hostname"
	} 
else 
	{
	write-host "Ping Test Failed for $hostname" 
	exit 1
	}
	
## Test if the DNS record exists or not

try
	{  
	$dnscheck = [System.Net.DNS]::GetHostByName($hostname)
	$test = $true
	}  
catch
	{
	Write-Output "Unable to resolve DNS for $hostname"
	exit 1
	}
	
## Do some verification if DNS record exists

if($test)
	{

## Check time taken in Milliseconds to resolve hostname

	$start_time = Get-Date 
	nslookup $hostname
	$timetaken = $((Get-Date).Subtract($start_time).Milliseconds)
	Write-Output "Time taken: $timetaken Milliseconds"
if ($timetaken -ge $time) 
	{
	write-host "DNS lookup for $hostname took longer than $time Milliseconds"
	exit 1
	}
	else 
	{ 
	Write-Output "Everything appears fine with your DNS for $hostname" 
	exit 0
	}
	}


Exit $LASTEXITCODE

<!-- gh-comment-id:750371149 --> @dinger1986 commented on GitHub (Dec 23, 2020): I have written one for powershell, does this suit your needs? Just upload to tactical scripts and change $hostname and $time Does a ping, checks it can resolve and then times the lookup. ``` ## name of hostname to run DNS checks against please leave the name in brackets $hostname = 'bbc.com' ## allowed time for DNS check to be done (Milliseconds) $time = 100 write-host -NoNewLine "Verifying" $hostname " ... " ## Do a ping test to ensure hostname can be contacted if (Test-Connection $hostname -Count 1 -ErrorAction SilentlyContinue) { write-host "Ping test passed for $hostname" } else { write-host "Ping Test Failed for $hostname" exit 1 } ## Test if the DNS record exists or not try { $dnscheck = [System.Net.DNS]::GetHostByName($hostname) $test = $true } catch { Write-Output "Unable to resolve DNS for $hostname" exit 1 } ## Do some verification if DNS record exists if($test) { ## Check time taken in Milliseconds to resolve hostname $start_time = Get-Date nslookup $hostname $timetaken = $((Get-Date).Subtract($start_time).Milliseconds) Write-Output "Time taken: $timetaken Milliseconds" if ($timetaken -ge $time) { write-host "DNS lookup for $hostname took longer than $time Milliseconds" exit 1 } else { Write-Output "Everything appears fine with your DNS for $hostname" exit 0 } } Exit $LASTEXITCODE ```
Author
Owner

@johnnyq commented on GitHub (Dec 24, 2020):

@dinger1986 Thanks a Lot! That's exactly what I was looking for, im sure this will help others too

<!-- gh-comment-id:750652128 --> @johnnyq commented on GitHub (Dec 24, 2020): @dinger1986 Thanks a Lot! That's exactly what I was looking for, im sure this will help others too
Author
Owner

@dinger1986 commented on GitHub (Dec 24, 2020):

No problems, if you check scripts on the tactical discord kyt has tidied it up quite a bit, mine works his is tidier!

<!-- gh-comment-id:750654556 --> @dinger1986 commented on GitHub (Dec 24, 2020): No problems, if you check scripts on the tactical discord kyt has tidied it up quite a bit, mine works his is tidier!
Author
Owner

@dinger1986 commented on GitHub (Dec 26, 2020):

Think this has now been dealt with?

<!-- gh-comment-id:751349739 --> @dinger1986 commented on GitHub (Dec 26, 2020): Think this has now been dealt with?
Author
Owner

@johnnyq commented on GitHub (Dec 26, 2020):

Absolutely Closing this Thanks

<!-- gh-comment-id:751373046 --> @johnnyq commented on GitHub (Dec 26, 2020): Absolutely Closing this Thanks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tacticalrmm#2082
No description provided.