Posted By

oktane on 04/25/09


server game windows batch DNS flushdns ipconfig nslookup

Versions (?)

Who likes this?

4 people have marked this snippet as a favorite


ipconfig flushdns batch file, for host DNS A changes, help users to resolve new host

 / Published in: DOS Batch

  1. @echo off
  2. rem Set this to the hostname that you just updated the A record on
  3. set
  4. rem Set this to the new A record address
  5. set correctip=
  6. nslookup %hostchk%|| goto errornons
  7. rem this is tricky, look for two of the strings "Address"
  8. nslookup -type=A %hostchk% 2>nul | find /c "Address" | find "2" > nul
  9. for /f "tokens=2" %%a in ('nslookup %hostchk%') do set curhostip=%%a
  10. cls
  11. Echo Your computer thinks %hostchk% goes to %curhostip%
  12. if /i "%curhostip%"=="%correctip%" goto allgood
  13. goto flush
  15. :allgood
  16. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  17. echo That's CORRECT, you're all set for the server transition!
  18. echo When the server comes online, you'll be ready to go.
  19. echo Make sure all your programs reference %hostchk% and not an IP.
  20. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  22. :error
  23. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  24. Echo For some reason, your computer cannot look up %hostchk%.
  25. Echo Put help text here
  26. Echo Be sure to tell us this error: can't resolve %hostchk%
  27. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  28. :errornons
  29. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  30. Echo Your computer doesn't have nslookup so this batch file won't work.
  31. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  32. :error2
  33. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  34. Echo For some reason, your computer or ISP still cannot find the right IP
  35. Echo Put help text here
  36. Echo Be sure to tell us this error: got wrong ip %curhostip%
  37. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  40. :flush
  41. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  42. echo That's INCORRECT, it should be %correctip%, so lets flush the DNS cache
  43. echo now and see if it will help.
  44. ipconfig /flushdns
  45. Echo After you press a key, we'll see if flushing the cache worked.
  46. echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  47. for /f "tokens=2" %%a in ('nslookup %hostchk%') do set curhostip=%%a
  48. cls
  49. if /i "%curhostip%"=="%correctip%" goto allgood
  50. goto error2

Report this snippet  


RSS Icon Subscribe to comments
Posted By: Vordreller on April 27, 2009

And what does this do exactly?

Posted By: on January 25, 2019

download best software to android root use app kingo or 360 for pc mac ios windows 10 8 1 7 xp computer this website

You need to login to post a comment.