Owing I need to move workplace from office to customer site lately, I need to change my laptop's IP address as I change workplace. So I edit a batch file to set my static IP address automatically.
Syntax
Let’s say I want to give my Windows 7 system an IP address of 10.144.38.195, a subnet mask of 255.255.255.0, a default gateway of 10.144.38.254. Type the following command and save as a batch file with encoding with ANSI
The address will be found via netsh interface ipv4 show interfaces command.
Idx Met MTU 狀態 名稱
--- ---------- ---------- ------------ ---------------------------
1 50 4294967295 connected Loopback Pseudo-Interface 1
13 50 1500 disconnected 無線網路連線
12 1 1500 disconnected 區域連線
19 30 1500 disconnected 區域連線 2
16 40 1500 disconnected Bluetooth 網路連線
20 20 1500 connected 區域連線 3
In this case, I would like to configure 區域連線. So the address name="區域連線"
Step by step
Step1. open command prompt.
Step2. execute the batch script file, i.e.SetIP4Office.bat
C:\Users\albert\Desktop>SetIP4Office.bat
C:\Users\albert\Desktop>netsh interface ipv4 set address name="區域連線" source=static address=10.14
4.38.195 mask=255.255.255.0 gateway=10.144.38.254
Well Done!
So you can edit different batch files to set different IP address for different workplace.
Reference
[1] http://www.windowsreference.com/networking/how-to-set-staticdhcp-ip-address-from-command-line/
No comments:
Post a Comment