WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

TCPIP and IP Address

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Use the NETSH Command to Change from Static IP Address to DHCP in Windows 2000

Keywords: Change from Static IP Address to DHCP

Question:

How can I change the Static IP address to DHCP?

Answer:

Would the NETSH resource kit utility work for what you need? See MS article Q257748 for a description of the tool.

In a nutshell, you can use this utility to change from/to DHCP or set an IP address/subnet mask/gateway from the command line. If you needed to set WINS or DNS entries, you can still push them into the registry.

Example:

RunWait('Netsh.exe','interface ip set address "Local Area Connection" static %dev4ip% %subnet% %gw% 1') 

SUMMARY

You can use the netsh command in Windows 2000 to script the process of changing a computer from a static Internet Protocol (IP) address to Dynamic Host Configuration Protocol (DHCP) or vice versa. The netsh command accomplishes this task without the need to restart the computer. This feature is particularly useful for laptops that move from one environment to another, when it is necessary to use statically assigned IP addresses at one location and DHCP assigned IP addresses at another.


MORE INFORMATION

To switch the specified adapter from a static address to DHCP, type the following command:

netsh interface ip set address "Local Area Connection" dhcp
NOTE: Typing this command changes the interface named "Local Area Connection" to DHCP.

To display all of the adapters in the computer with their current IP addresses to determine the correct adapter name, type the following command:
netsh interface ip show ipaddress
To change to a static address, type the following command:
netsh interface ip set address "Local Area Connection" static ipaddr subnetmask gateway metric
NOTE: Replace ipaddr with the static IP address, subnetmask with the subnet mask, gateway with the default gateway and, if necessary, metric with the appropriate metric. The following example changes the interface "Local Area Connection" to a static address of 192.168.0.10 with a subnet mask of 255.255.255.0, and the interface has a default gateway of 192.168.0.1 with a metric of 1:
netsh interface ip set address "Local Area Connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1


Article ID:   W14975
File Created: 2001:11:08:12:41:16
Last Updated: 2001:11:08:12:41:16