Question

I have a couple of systems in my office with incorrect DNS Settings....

I wanna do a sweep of all systems.

how can I check if my systems have the correct DNS?

ie my DNS address is 1.1.1.1?

Thanks in advance. This is what i was working on. @echo off REM This is to check DNS

set dnsAddy= "ipconfig /all | findstr Servers | findstr /V 1.1.1.1"
If %dnsAddy% = null then
exit 0
fi echo "DNS is incorrect"
Was it helpful?

Solution

isDns.bat

ipconfig /all | findstr "Servers" | findstr "1.1.1.1"

If you wanted to pass the IP address in

ipconfig /all | findstr "Servers" | findstr "%1"

To use the 2nd version you would type isDns 1.1.1.1 from a command prompt.

In either case you will get no output if the DNS entry does not match.



Edit following question clarification

ipconfig /all | findstr "Servers" | findstr "1.1.1.1"
IF %ERRORLEVEL% EQU 0 (echo "You're good!") ELSE (echo "Bad config")

OTHER TIPS

I couldn't figure it out in command... but i was able to put this vbscript together. and it works.

Dim objShell, myDNS, myDNScmd
Set objShell = WScript.CreateObject ("WScript.shell")
myDNScmd = "ipconfig /all | findstr ""Servers"" | findstr /V 1.1.1.1"
myDNS = objShell.run ("%comspec% /c " & myDNScmd,0,True)
'wscript.echo myDNS
If myDNS = 1 then
    'wscript.echo "CORRECT - DNS Server is set to 1.1.1.1"
    wscript.quit 0
else
    'wscript.echo "WRONG - DNS Server is not set to 1.1.1.1"
    wscript.quit 123456
end if
objShell.Close
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top