1 Click to change Network IP Properties
Do you change your network properties often?Many people do.
When we are in the office, for some reasons it can be that the computer needs to be supplied with IP address, Gateway numbers, DNS numbers (primary and secondary). Then when we go out and open a computer in a coffee shop, the network is free and we need to go and change network IP setup to ‘Obtain IP automatically’ and set following lines.
I’m not sure how others think about it. For me, it’s distracting that we have to go somewhat lengthy steps to change all these.
We can find out that there are commands, we can write in (DOS) prompt – press Enter – and computer will execute.
see: http://tweaks.com/windows/40339/configure-ip-address-and-dns-from-command-line/
* Thanks to http://tweaks.com for documenting these.
To change and set IP from command prompt:
netsh interface ip set address name=”Local Area Connection” static 192.168.10.100 255.255.255.0 192.168.10.1 1
- “Local Area Connection” is the name of the network adapter you want to modify. Or you can change this to “Wireless Network Connection” or “Wifi-1″.
Match it to a name of your network as found in:
Control Panel\Network and Internet\Network Connections - 192.168.10.100 is the IP address you want to set.
- 255.255.255.0 is the subnet mask.
- 192.168.10.1 is the gateway.
- 1 is the gateway metric. You can leave this as 1 for almost all cases.
To change to automatic IP or DHCP :
netsh interface ip set address name=”Local Area Connection” dhcp
To set DNS –
for Primary DNS:
netsh interface ip set dns name=”Local Area Connection” static 8.8.8.8
for Secondary DNS:
netsh interface ip add dns name=”Local Area Connection” 4.4.4.4 index=2
If you want to configure the computer to use DNS from DHCP run:
netsh interface ip set dnsservers name=”Local Area Connection” source=dhcp
Having know all these, we can take 1 further step to write one or few batch (.BAT) files to accommodate configurations for all networks that we need to connect to.
With notepad, we can paste lines, and save it as .BAT.
These are few ideas:
E.g. When in the office, you need to set IP: 192.168.10.100, primary DNS: 8.8.8.8, secondary DNS: 4.4.4.4 ; write as follow:
netsh interface ip set address name=”Local Area Connection” static 192.168.10.100 255.255.255.0 192.168.10.1 1
netsh interface ip set dns name=”Local Area Connection” static 8.8.8.8
netsh interface ip add dns name=”Local Area Connection” 4.4.4.4 index=2
Save this as “network – office.BAT”
E.g. When in the warehouse or production site, you need to set to different IP: 192.168.10.222, primary DNS: 8.8.8.8, secondary DNS: 4.4.4.4 ; write as follow:
netsh interface ip set address name=”Local Area Connection” static 192.168.10.222 255.255.255.0 192.168.10.1 1
netsh interface ip set dns name=”Local Area Connection” static 8.8.8.8
netsh interface ip add dns name=”Local Area Connection” 4.4.4.4 index=2
Save this as “network – warehouse_production.BAT”
E.g. and you need to set 1 more for automatic IP / DHCP to use when you are in a public place, like restaurant, coffee shop, air port, etc..
To set automatic IP, but use Google’s DNS ; write as follow:
netsh interface ip set address name=”Local Area Connection” dhcp
netsh interface ip set dns name=”Local Area Connection” static 8.8.8.8
netsh interface ip add dns name=”Local Area Connection” 4.4.4.4 index=2
Save this as “network – autoIP fixDNS.BAT”
To set automatic IP, and automatic DNS too; write as follow:
netsh interface ip set address name=”Local Area Connection” dhcp
netsh interface ip set dnsservers name=”Local Area Connection” source=dhcp
Save this as “network – autoIP_DNS.BAT”
Please remember, these .BAT files need to “Run as Administrator” to take effect.
If you want to, you can set “Run as Adminstrator” for each shortcut;
- right click – Properties – (in ‘Shortcut’ tab) click Advance
- put checkmark in “Run as Administrator”
Now there are 4 files to serve all the possibilities. From now on, wherever we are, we only need 1 click (or another 1 or 2 more, for confirmations) to change network properties.
Please comment if you have opinion or please share also if you have better implementation.
Filed under: Computers and Internet, PC Tagged: automation, configure, DNS, fix, IP, joemarselo, LAN, microsoft, parameters, scripting, setting, shell

This was originally posted here.
*This post is locked for comments