JSI Tip 2279. Switch from DHCP to Static IP address, and visa-versa, using NETSH.

Jerold Schulman

April 13, 2000

1 Min Read
ITPro Today logo in a gray background | ITPro Today


When moving from site to site, it is often necessary to switch between static IP addressing and DHCP.

This used to be a real pain.

Using the NETSH command on my Windows 2000 laptop, I script it, without the need to even restart.

To implement this technique, determine what adapters / IP addresses you currently have by typing:

NETSH interface ip show ipaddress

If you have 2 NICs, the result would look something like:

MIB-II IP Address EntryIP Address       Mask             BC Fmt  Reasm Sz  Interface---------------  ---------------  ------  --------  -----------------------127.0.0.1        255.0.0.0             1     65535  Loopback192.168.0.50     255.255.255.0         1     65535  Local Area Connection216.144.1.126    255.255.254.0         1     65535  Internet

NOTE: The RemoteAccess service must be started. If it is Disabled, set it to Manual or Automatic. Then type net start remoteaccess.

To switch the Local Area Connection to DHCP, type:

netsh interface ip set address "Local Area Connection" dhcp

To change the Local Area Connection to a static ip address, type:

netsh interface ip set address "Local Area Connection" static
netsh interface ip set address "Local Area Connection" gateway = gwmetric =

where:

is the ip address.

is the subnet mask.

is the default gateway.

is the metric.

To change the Local Area Connection to 192.168.0.50, subnet mask 255.255.255.0, default gateway 192.168.0.1 and a metric of 1, type:

netsh interface ip set address "Local Area Connection" static 192.168.0.50 255.255.255.0
netsh interface ip set address "Local Area Connection" gasteway = 192.168.0.1 gwmetric = 1

NOTE: Type netsh interface ip dump to see the settings of a configured PC.



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like