Configuring static IP and DHCP on Windows

This article will cover a quick method to configure network connection under Windows.

Let's say you have a lap-top computer that you use in two different places. The first one is with static IP address with following paramethers:

Network mask:

Static IP configuration

In the other place you use DHCP.

Dynamic IP (DHCP)

When you need to switch from statis IP to DHCP you just toggle a radio button. But the opposite action takes a lot of time enterin IP address, mask and so on. This article will help you to save this typing.

The netsh application

Netsh is an useful conzole application for managing network interfaces. It has a plenty of capabilities, but we'll limit to some of them. Full description can be found on

We'll use .bat files to list both configuration. You can read more on these files on

You have to know the name of the interface that you'll setup. This can be done from Start -> Control panel -> Network connections (see picture). In our case this will be "Local Area Connection". If you computer has more than one LAN cads (network interfaces), check witch is the one where you plug the cable in. If you want to ajust you wireless connection then in the picture this is "Wireless Network Connection".

Network connections

Static IP address

To ajust a static IP address, create the file static.bat containing:

netsh interface ip set address name="Local Area Connection" static 1
netsh interface ip set dns "Local Area Connection" static
netsh interface ip set wins "Local Area Connection" static

First command sets IP with subnet mask and gateway Second command setups DNS server address, and third - WINS server address.

Dynamic IP address (DHCP)

Create file dhcp.bat:

netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns "Local Area Connection" dhcp

If you DNS is not set up automatically, content of the file should be:

netsh interface ip set address "Local Area Connection" dhcp
netsh interface ip set dns "Local Area Connection" static

where is the IP address of DNS server.

And final touches

Create above files in My documents folder. Put shortcuts on your desktop to both of them. Now instead of changing network setup manually, just double-click on of the files.



Galin Stoyanov (12-07-2009 23:54) :
It helps alot. Thank you. But will this work with WiFi and should I replace "Local Area Connection" with "Wireless Network Connection" only to make it work?

Back to articles list

This page was last modified on 2024-07-18 18:18:37