네트워크 갱신


@echo off
rem Set this to the hostname that you just updated the A record on
set hostchk=server.example.org
rem Set this to the new A record address
set correctip=127.127.127.127
nslookup %hostchk%|| goto errornons
rem this is tricky, look for two of the strings "Address"
nslookup -type=A %hostchk% 2>nul | find /c "Address" | find "2" > nul
if ErrorLevel 1 goto error
for /f "tokens=2" %%a in ('nslookup %hostchk%') do set curhostip=%%a
cls
Echo Your computer thinks %hostchk% goes to %curhostip%
if /i "%curhostip%"=="%correctip%" goto allgood
goto flush

:allgood
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo That's CORRECT, you're all set for the server transition!
echo When the server comes online, you'll be ready to go.
echo Make sure all your programs reference %hostchk% and not an IP.
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit

:error
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Echo For some reason, your computer cannot look up %hostchk%.
Echo Put help text here
Echo Be sure to tell us this error: can't resolve %hostchk%
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit
:errornons
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Echo Your computer doesn't have nslookup so this batch file won't work.
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit
:error2
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Echo For some reason, your computer or ISP still cannot find the right IP
Echo Put help text here
Echo Be sure to tell us this error: got wrong ip %curhostip%
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit

:flush
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo That's INCORRECT, it should be %correctip%, so lets flush the DNS cache
echo now and see if it will help.
ipconfig /flushdns
Echo After you press a key, we'll see if flushing the cache worked.
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
for /f "tokens=2" %%a in ('nslookup %hostchk%') do set curhostip=%%a
cls
if /i "%curhostip%"=="%correctip%" goto allgood
goto error2


'Infrastructure' 카테고리의 다른 글

오피스 2013 한글 및 다국어 언어팩  (0) 2013.06.27
iis mime 설정  (0) 2013.06.26
Ipconfig  (0) 2013.06.17
로컬 사용자 및 그룹 나타나지 않을 때  (0) 2013.05.31
IIS 백업과 복원  (0) 2013.05.30

+ Recent posts