如何快速切换静态和动态ip
@echo off
rem eth //eth 為網(wǎng)卡名稱,可在網(wǎng)絡(luò)連接中查詢,如"本地鏈接"
set eth="本地連接"
rem ip //ip 為你想更改的IP
set ip=202.198.24.125?
rem gateway //gateway 為網(wǎng)關(guān)地址
set gateway=202.198.24.254
rem netmasks //netmasks 為子網(wǎng)掩碼
set netmasks=255.255.255.0
rem dns //dns 為首選DNS
set dns=202.98.18.3
rem dns2 //dns2 為備用DNS
set dns2=
echo 正在將本機(jī)IP更改到: %ip% 請(qǐng)等候...
rem
if %gateway%==none netsh interface ip set address %eth% static %ip% %netmasks% %gateway% > nul
if not %gateway%==none netsh interface ip set address %eth% static %ip% %netmasks% %gateway% 1 > nul
if %dns%==none netsh interface ip set dns %eth% static %dns%> nul
if not %dns%==none netsh interface ip set dns %eth% static %dns%> nul
if %dns2%==none netsh interface ip add dns %eth% %dns2%> nul
if not %dns2%==none netsh interface ip add dns %eth% %dns2% 2> nul
echo.........................
echo 檢查當(dāng)前本機(jī)IP:
ipconfig
echo.........................
echo 成功將本機(jī)IP更改為%ip%!
pause
close
將如上代碼保存為gotostatic.bat 執(zhí)行它即可轉(zhuǎn)換成靜態(tài)ip,紅色的地方指示的IP地址(192.168.1.12)、網(wǎng)關(guān)、DNS改為你所用的IP和網(wǎng)關(guān)
?
echo off
netsh interface ip set address? name ="本地連接" dhcp?
netsh interface ip set dns? name ="本地連接" dhcp???
pause
?
將如上代碼保存為gotodynamic.bat 執(zhí)行它即可轉(zhuǎn)換成動(dòng) 態(tài)ip
總結(jié)
以上是生活随笔為你收集整理的如何快速切换静态和动态ip的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 梅捷SY-A780G+冷启动黑屏,需Re
- 下一篇: 吴穹博士谈软件工程未来发展趋势