Total Pageviews


How to set Static IP Address from command line

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.

Let’s say I want to give my Windows 7 system an IP address of, a subnet mask of, a default gateway of Type the following command and save as a batch file with encoding with ANSI
 netsh interface ipv4 set address name="區域連線" source=static address= mask= gateway=  

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>netsh interface ipv4 set address name="區域連線" source=static address=10.14  
 4.38.195 mask= gateway=  

Well Done!

So you can edit different batch files to set different IP address for different workplace.


No comments: