Windows批處理:自動檢查網路連通性

來源:互聯網
上載者:User

標籤:指令碼   shell   ping   

  檢測網路連通性我用的是叢遠到近的方法,即“外網——網關——內網——本機”,指令碼的實現也是根據這個順序用ping來檢測,為提高檢測速度,這裡我只ping了2次,各位可以根據自己的需要進行修改。

  使用方法大神們都會的... 複製代碼,另存新檔.bat檔案後執行。


@echo offcolor 2Ftitle 網路連通性檢測echo.echo.ping -n 2 223.5.5.5>%temp%\1.ping & ping -n 2 223.6.6.6>>%temp%\1.ping    ::ping阿里公用DNSfindstr "TTL" %temp%\1.ping>nulif %errorlevel%==0 (echo     √ 外網正常) else (echo     × 外網不通)         ::根據傳回值輸出echo.ping -n 2 192.168.1.1>%temp%\2.pingfindstr "TTL" %temp%\2.ping>nulif %errorlevel%==0 (echo     √ 網關正常) else (echo     × 網關不通)echo.ping -n 2 192.168.1.2>%temp%\3.pingfindstr "TTL" %temp%\3.ping>nulif %errorlevel%==0 (echo     √ 內網正常) else (echo     × 內網不通)echo.ping -n 2 127.0.0.1>%temp%\4.pingfindstr "TTL" %temp%\4.ping>nulif %errorlevel%==0 (echo     √ TCP/IP協議正常) else (echo     × TCP/IP協議異常)if exist %temp%\*.ping del %temp%\*.ping                ::刪除快取檔案echo.echo.pause


效果如下:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/70/9C/wKiom1W5846ilqGmAADTlId_Kos005.jpg" title="1.png" alt="wKiom1W5846ilqGmAADTlId_Kos005.jpg" />


本文出自 “營運菜鳥.log” 部落格,請務必保留此出處http://sjy000.blog.51cto.com/8412654/1680241

Windows批處理:自動檢查網路連通性

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.