netsh interface ip set
command.
You should run the command from an account in the administrators group.
C:\>netsh interface ip set /? The following commands are available: Commands in this context: set address - Sets the IP address or default gateway to the specified interfa ce. set dns - Sets DNS server mode and addresses. set wins - Sets WINS server mode and addresses.
To set the IP address, you use the netsh interfce ip set address
command. To set the IP address to a static value, say 192.168.0.66, you could
use the command below.
C:\>netsh interface ip set address name="Local Area Connection" static 192.168.0 .66 255.255.255.0 192.168.0.1 1 Ok.
You may need to wait a minute for the OK to be displayed.
Don't forget the 1
at the end specifying the metric for the
default gateway. The syntax of the command is explained below.
C:\>netsh interface ip set address /? Usage: set address [name=][[source=]dhcp | [source=] static [addr=]IP address [mask=]IP subnet mask] [[gateway=] |none [gwmetric=]integer] Parameters: Tag Value name - The name of the interface. source - One of the following values: dhcp: Sets DHCP as the source for configuring IP addresses for the specific interface. static: Sets the source for configuring IP addresses to local static configuration. gateway - One of the following values: : A specific default gateway for the static IP address you are setting. none: No default gateways are set. gwmetric - The metric for the default gateway. This field should not be set if gateway is set to 'none'. The following options are used only if source is 'static': addr - An IP address for the specified interface. mask - The subnet mask for the specified IP address. Remarks: Used to change the IP address configuration mode from either DHCP to static mode or static mode to DHCP. Adds IP addresses on an interface with static IP address or adds default gateways. Examples: set address name="Local Area Connection" source=dhcp set address local static 10.0.0.9 255.0.0.0 10.0.0.1 1
After the netsh interface ip set address
, you need to select
the appropriate network connection, since a system may have multiple network
connections. If you are setting the information for a network card in the
PC, in most cases that will be "Local Area Connection". On a Windows XP system,
you can see the available network connections by clicking on Start,
then Settings, and then selecting Network Connections.
Next you need to select whether you want to use static IP address information
or have that information provided by a
DHCP server.
If the information is to be provided by a DHCP server, you need only enter
netsh interface ip set address name="Local Area Connection" dhcp
and hit Enter. If, instead, you wish to use static information then
you have additional parameters you need to specify, such as the IP address,
subnet mask, gateway
address, i.e. the default router to use, and the metric for that router.
The subnet mask is often 255.255.255.0
, but may be different
for your network. The router metric will typically be 1
, unless
you have access to more than one router on your subnet.
The command below will set the IP address to be 192.168.0.66
with a subnet mask of 255.255.255.0
, a gateway address of
192.168.0.1
and a metric of 1
for that gateway
address, meaning that router is the preferred router.
netsh interface ip set address name="Local Area Connection"
static 192.168.0.66 255.255.255.0 192.168.0.1 1
You can also set the
DNS servers from the command line using the command netsh interface
ip set dns
. To use DHCP provided values, use the command below.
netsh interface ip set dns "Local Area Connection" dhcp
To set the value to a static one, such as 192.168.0.53
, you
can use the command below.
netsh interface ip set dns "Local Area Connection" static 192.168.0.53
The syntax for the command to set DNS information, is shown below.
C:\>netsh interface ip set dns /? Usage: set dns [name=][source=]dhcp|static [addr=] |none [[register=]none|primary|both] Parameters: Tag Value name - The name of the interface. source - One of the following values: dhcp: Sets DHCP as the source for configuring DNS servers for the specific interface. static: Sets the source for configuring DNS servers to local static configuration. addr - One of the following values: : An IP address for a DNS server. none: Clears the list of DNS servers. register - One of the following values: none: Disables Dynamic DNS registration. primary: Register under the primary DNS suffix only. both: Register under both the primary DNS suffix, as well as under the connection-specific suffix. Remarks: Sets DNS server configuration to either DHCP or static mode. Only when source is 'static', is the 'addr' option also available for configuring a static list of DNS server IP addresses for the specified interface. Examples: set dns name="Local Area Connection" source=dhcp set dns "Local Area Connection" static 10.0.0.1 primary
References: