Differences
This shows you the differences between two versions of the page.
windows_wiki:batch_-_change_ip [2014/11/20 19:32] 127.0.0.1 external edit |
windows_wiki:batch_-_change_ip [2019/05/25 23:50] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Batch - Change IP Static/DHCP ====== | ||
- | Quickly change from/to static to dhcp. | ||
- | < | ||
- | @echo off | ||
- | rem Program: ip.bat | ||
- | rem Author: Bill Howe | ||
- | rem Version: 1.0 | ||
- | rem Date: 03/15/2012 | ||
- | rem Description: | ||
- | rem on the specified network interface. | ||
- | echo. | ||
- | |||
- | if " | ||
- | goto staticip | ||
- | )else if " | ||
- | goto dhcp | ||
- | )else ( | ||
- | goto error) | ||
- | |||
- | :staticip | ||
- | echo ==Static IP Config== | ||
- | echo. | ||
- | |||
- | echo --- Available Interfaces --- | ||
- | netsh interface show interface | ||
- | set INTERFACE=Local Area Connection | ||
- | set /p INTERFACE= ">> | ||
- | echo. | ||
- | |||
- | echo -- %INTERFACE% -- | ||
- | set IPADDR=192.168.1.50 | ||
- | set /p IPADDR= Enter IP Address[192.168.1.50]: | ||
- | set MASK=255.255.255.0 | ||
- | set /p MASK= Enter Subnet Mask[255.255.255.0]: | ||
- | set GW=" | ||
- | set /p GW= Enter Gateway[192.168.1.1]: | ||
- | set DNS=8.8.8.8 | ||
- | set /p DNS=Enter DNS[8.8.8.8]: | ||
- | |||
- | echo. | ||
- | echo Setting interface information... | ||
- | netsh interface ipv4 set address " | ||
- | netsh interface ipv4 set dnsservers " | ||
- | |||
- | rem Wait 5 seconds and then show the ipconfig of local area connection | ||
- | ping -n 6 127.0.0.1 > nul | ||
- | netsh interface ip show address " | ||
- | goto end | ||
- | |||
- | :dhcp | ||
- | echo ==DHCP Config== | ||
- | |||
- | echo --- Available Interfaces --- | ||
- | netsh interface show interface | ||
- | set INTERFACE=Local Area Connection | ||
- | set /p INTERFACE= ">> | ||
- | echo. | ||
- | |||
- | echo -- %INTERFACE% -- | ||
- | echo Attempting to get DHCP for %INTERFACE%... | ||
- | netsh interface ipv4 set address " | ||
- | netsh interface ipv4 set dnsservers name=" | ||
- | |||
- | rem Wait 5 seconds and then show the ipconfig of local area connection | ||
- | ping -n 6 127.0.0.1 > nul | ||
- | netsh interface ip show address " | ||
- | goto end | ||
- | |||
- | :error | ||
- | echo ==IP Command Help== | ||
- | echo ip syntax: | ||
- | echo ip static = Invoke static IP prompts. | ||
- | echo ip dhcp = Attempt to automatically obtain an IP address. | ||
- | echo. | ||
- | |||
- | :end | ||
- | </ |