Use netsh to set interface IP static or dhcp

This content 4 years old. Please, read this page keeping its age in mind along with the fact technology changes fast and the information on this page me be outdated, not best practice, or plain wrong.

Get Configuration Info

Using the command below, you can gather information on the adapter’s current configuration. Make note of the connection name since that is what is used to in the configuration command further down.

netsh interface ip show config
Figure 1 - Example of netsh interface ip show config

Figure 1 – Example of netsh interface ip show config

You can see the existing configuration with the following command.

netsh interface ip dump
2016-05-05_113938

Figure 2 – Example of netsh interface ip dump

Set Interface DHCP

To set interface address as DHCP, issue the following.  Change the items highlighted in Red to suite your environment.

Note:  Use the above command (netsh interface ip dump) to figure out which interface you need to use.  Default is “Local Area Connection” but many environments will differ.  Match the interface= portion and supply that in the Red sections below.  I’m leaving the default of “Local Area Connection” but you can see that my interface would be “Ethernet”.

2016-05-05_113938-2

Figure 3 – Determine the interface name to use when configuring the interface via netsh

netsh interface ip set address "Local Area Connection" dhcp

You also can set the DNS statically or via DHCP as well.

netsh interface ip set dns "Local Area Connection" 8.8.4.4

Set a secondary DNS server:

netsh interface ip set dns "Local Area Connection" 8.8.4.4 index=2

Set Interface Static

Set the interface with a static address. Change the items in Red to suite your environment.

netsh interface ip set address "Local Area Connection" static ipaddr subnetmask gateway metric

Set the DNS server statically.

netsh interface ip set dns "Local Area Connection" 8.8.4.4

Set a secondary DNS server:

netsh interface ip set dns "Local Area Connection" 8.8.4.4 index=2

Speak Your Mind

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.