Quick Links

Key Takeaways

  • You must launch Command Prompt, PowerShell, or Terminal as admin to use netsh.
  • Use the "netsh interface ipv4 show config" command to find the full name of the network interface you want to change.
  • Modify your IP address, subnet mask, and default gateway using the command "netsh interface ipv4 set address". You can also change DNS settings using "netsh interface ipv4 set dns".

Changing your IP address with the Control Panel interface isn't difficult, but it does require clicking through a number of different windows and dialog boxes. If you're a fan of the Command Prompt, though, you can get it done more quickly using the netsh command, which is just one of the great network utilities built into Windows.

Launch Command Prompt as Admin to Use Netsh

We're going to use the netsh command, but it requires that Command Prompt be launched as administrator to work. The netsh command allows you to configure just about any aspect of your network connections in Windows.

To launch Command Prompt (or PowerShell) as Admin, open up the Start Menu, search "cmd," hover over the result, then click "Run as Administrator."

Run Command Prompt as administrator.

In Windows 10 or Windows 11, you can also right-click the Start menu (or press Windows+X on your keyboard) to open the Power User Menu and choose "PowerShell (Admin)."

You can (and should) use PowerShell for this instead.

View Your Network Information with Command Prompt

Before you change your IP address and related information, you'll need to find the full name of the network for the interface you want to change. To do this, type the following command:

netsh interface ipv4 show config

The output of netsh interface ipv4 show config. The Wi-Fi adapter is highlighted in red.

Scroll down until you see the interface you're looking for. In our example, we're going to modify the Wi-Fi interface, which on our machine is just named "Wi-Fi." You'll also see other default names that Windows assigns to interfaces, such as "Local Area Connection," "Local Area Connection* 2," and "Ethernet." Just find the one you're looking for and make note of the exact name. You can also copy and paste the name to Notepad and then back into Command Prompt later to make things easier.

Change Your IP Address, Subnet Mask, and Default Gateway

With the interface name in hand, you're ready to change the IP Address, subnet mask, and gateway. To do this, you'll issue a command using the following syntax:

netsh interface ipv4 set address name="YOUR INTERFACE NAME" static IP_ADDRESS SUBNET_MASK GATEWAY

So, for example, your command might look something like the following:

netsh interface ipv4 set address name="Wi-Fi" static 192.168.3.8 255.255.255.0 192.168.3.1

Where the info is replaced by whatever you want to use. In our example, the command does the following:

  • Uses the interface name "Wi-Fi"
  • Sets the IP address to 192.168.3.1
  • Sets the subnet mask to 255.255.255.0
  • Sets the default gateway to 192.168.3.1

And if you're using a static IP address but want to switch to using an IP address assigned automatically by a DHCP server — such as your router — you can use the following command instead:

netsh interface ipv4 set address name="YOUR INTERFACE NAME" source=dhcp

Change Your DNS Settings in Command Prompt

You can also use the netsh command to change the DNS servers used by a network interface. Third-party DNS servers — like Google Public DNS and OpenDNS —can be faster and more reliable than the DNS servers provided by your ISP. Whatever your reason for changing your DNS server, you can do it either at the router so it affects all the devices that get their information from the router or at the individual device. If you want to change the DNS servers for just one PC, it's easy to do with the netsh command.

You'll need to use the command twice: once to set your primary DNS server and once to set your secondary, or backup, DNS server. To set your primary DNS server, use the following syntax:

netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER

So, for example, your command might look something like the following (in which we set it to Google's primary public DNS server, 8.8.8.8):

netsh interface ipv4 set dns name="Wi-Fi" static 8.8.8.8

To set your secondary DNS server, you'll use a very similar command:

netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER index=2

So, continuing our example, you might set your secondary DNS as the Google Public DNS secondary server, which is 8.8.4.4:

netsh interface ipv4 set dns name="Wi-Fi" static 8.8.4.4 index=2

And just like with the IP address, you can also change it so that the network interface grabs its DNS settings automatically from a DHCP server instead. Just use the following command:

netsh interface ipv4 set dnsservers name"YOUR INTERFACE NAME" source=dhcp

And there you have it. Whether you like typing at the command prompt better or just want to impress your coworkers, now you know all the command line magic you need for changing your IP address settings.