Using batch processing to simplify the Windows IP Setup process

Source: Internet
Author: User

As a system integration engineer, especially in the new project deployment, need to deal with a lot of hardware equipment-server, storage, network equipment, operating system will have its own IP address segment, and this time only through the notebook direct connection for debugging configuration, using the Windows interface to set the IP operation is too cumbersome, Will waste a lot of APM650) this.width=650; "src=" Http://img.baidu.com/hi/face/i_f27.gif "alt=" I_f27.gif "/> just take advantage of the first day of New Year's work, This paper studies how to configure IP through scripting.


(The debugging environment for this article is Win7 Simplified Chinese flagship edition)


Core command:

netsh interface ip set address network adapter name static IP MASK GATEWAY

netsh interface ip set address local connection static 192.168.0.50 255.255.255.0 192.168.0.1


Batch script: (Based on Baidu Library article fine-tuning)

@echo off
Cls
Color 0A
echo IP Address Change gadget
Set ip=192.168.1.2
Set mask=255.255.255.0
Set gateway=0.0.0.0
Set name= "Local Area Connection"


Echo.
echo Auto Change IP Press 1
Echo.
Echo To manually change the IP, press 2
Echo.
echo Recovery Auto-GET, press 3

set/p key= [Your choice is:]
if%key% = = 1 Goto One
if%key% = = 2 Goto
if%key% = = 3 goto Three


: both
ECHO you have chosen to modify the settings manually.
ECHO.
echo Default IP address is%ip%, enter default address
set/p ip= [Please enter IP address:]
Echo.
echo Default MASK is%mask%, enter default value
set/p mask= [Please enter the subnet mask address:]
Echo.
echo Default GATEWAY is%gateway%, enter default value
set/p gateway= [Please enter the gateway address:]
Echo.
ECHO is automatically changing IP ...
netsh interface ip set address%NAME% static%ip%%mask%%gateway%
echo IP address/subnet mask/Gateway Setup complete
Pause
Goto:eof

: one
ECHO is automatically changing IP ...
netsh interface ip set address%NAME% static%ip%%mask%%gateway%
echo IP address/subnet mask/Gateway Setup complete
Pause
Goto:eof

: Three
Echo is changing to automatically get ....
netsh interface ip set address%NAME% source=dhcp
netsh interface ip set DNS%NAME% SOURCE=DHCP
Pause:eof


1, the habit of open cmd students can put the bat file under the C:\Windows\System32, so that in any path can be called.

2, note that in the case of local connection network port down, from the static IP to DHCP can not see the effect, plug in the network cable is effective

3, the single network card set multiple IP can use the command:

netsh interface ip add address network adapter name static IP MASK GATEWAY

The test is available, and tomorrow we'll study how to change the batch process.

Using batch processing to simplify the Windows IP Setup process

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.