Windows

How to Use Netsh to Configure Network Interfaces on Windows

This tutorial will discuss various netsh commands to configure multiple network properties in a Windows system.
Captain Salem 5 min read
How to Use Netsh to Configure Network Interfaces on Windows

Windows

Network Shell, commonly known as Netsh, is a command-line tool in Windows that allows administrators to configure and manage various networking components, such as network interfaces, IP addresses, DNS servers, and more. It is included in all modern versions of Windows and can be accessed through the Command Prompt or PowerShell.

Netsh uses a dynamic-link library (DLL) file set that implements the network shell functionality. These DLL files contain the code that performs the various network operations that can be configured using Netsh. When a Netsh command is executed, the corresponding DLL file is loaded into memory, and the appropriate functions are called to perform the requested operation.

For example, if a command to configure a network interface is executed, the DLL file that implements the network interface configuration functions is loaded, and the appropriate functions are called to perform the configuration.

Netsh provides a command-line interface for interacting with these DLL files and calling the appropriate functions. The syntax for Netsh commands can be complex, with many options and parameters that must be specified correctly to perform the desired operation.

Netsh also supports scripting, which allows administrators to automate complex network configuration tasks using batch files or PowerShell scripts. By combining multiple Netsh commands into a script, administrators can quickly and efficiently perform network configuration tasks across multiple computers or network devices.

How to Access the Network Shell

In Windows, we can access netsh using the Command Prompt or Windows PowerShell.

Open Command Prompt with administrative privileges. Click on the Start menu, type cmd, right-click on Command Prompt, and select "Run as administrator."

In the command prompt, you can open the network shell by running the command:

netsh

This should open the netsh prompt and allow you to configure networks:

netsh>

Netsh Show Available Network Interfaces

To view a list of all available network interfaces, type the following command and press Enter:

netsh> interface show interface

This will display a list of all network interfaces along with their names and statuses.

Admin State    State          Type             Interface Name
-------------------------------------------------------------------------
Enabled        Connected      Dedicated        VMware Network Adapter VMnet1
Enabled        Connected      Dedicated        VMware Network Adapter VMnet8
Enabled        Connected      Dedicated        Wi-Fi
Enabled        Disconnected   Dedicated        Ethernet
Enabled        Disconnected   Dedicated        Local Area Connection

Netsh Configure Specific Network Interface

To configure a specific network interface, use the following command:

netsh> interface ipv4 set address "<interface name>" static <IP address> <subnet mask> <default gateway>

Where

  1. <interface name> is the name of the network interface you want to configure.
  2. <IP address> is the desired IP address of the interface.
  3. <subnet mask> refers to the subnet mask for the network.
  4. Finally, the <default gateway> is the IP address of the default gateway.

For example, if you want to configure the interface named "Ethernet", and assign it the IP address 192.168.1.100 with a subnet mask of 255.255.255.0 and a default gateway of 192.168.1.1, you would enter the following command:

netsh interface ipv4 set address "Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1

Netsh Configure DNS Servers

To configure DNS servers, use the following command:

netsh> interface ipv4 add dnsserver "<interface name>" <DNS server address> index=1

Where:

  1. <interface name> is the name of the network interface you want to configure.
  2. <DNS server address> is the IP address of the DNS server you want to use.

You can add multiple DNS servers by repeating this command with a different IP address and index number. For example, if you want to configure the DNS server for the "Ethernet" interface to use the IP address 8.8.8.8, you would enter the following command:

netsh> interface ipv4 add dnsserver "Ethernet" 8.8.8.8 index=1

Note that the index number determines the order in which DNS servers are used. The DNS server with the lowest index number is used first, followed by the next lowest index number, and so on.

Once you have configured the network interface, you can verify the settings by typing the following command and pressing Enter:

ipconfig /all

This will display the IP address, subnet mask, default gateway, and DNS server information for all network interfaces on the system.

Example output:

Wireless LAN adapter Local Area Connection* 10:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : Microsoft Wi-Fi Direct Virtual Adapter #2
   Physical Address. . . . . . . . . : E6-5E-37-13-A4-AC
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes

Ethernet adapter VMware Network Adapter VMnet1:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet1
   Physical Address. . . . . . . . . : 00-50-56-C0-00-01
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::f075:63f4:6d8c:a424%5(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.154.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Saturday, April 8, 2023 2:46:34 PM
   Lease Expires . . . . . . . . . . : Saturday, April 8, 2023 8:46:34 PM
   Default Gateway . . . . . . . . . :
   DHCP Server . . . . . . . . . . . : 192.168.154.254
   DHCPv6 IAID . . . . . . . . . . . : 704663638
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2B-B8-05-2E-08-97-98-BC-C3-01
   NetBIOS over Tcpip. . . . . . . . : Enabled

Ethernet adapter VMware Network Adapter VMnet8:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : VMware Virtual Ethernet Adapter for VMnet8
   Physical Address. . . . . . . . . : 00-50-56-C0-00-08
   DHCP Enabled. . . . . . . . . . . : Yes
   Autoconfiguration Enabled . . . . : Yes
   Link-local IPv6 Address . . . . . : fe80::26a3:8076:a2eb:df88%17(Preferred)
   IPv4 Address. . . . . . . . . . . : 192.168.136.1(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Lease Obtained. . . . . . . . . . : Saturday, April 8, 2023 2:46:34 PM
   Lease Expires . . . . . . . . . . : Saturday, April 8, 2023 8:46:34 PM
   Default Gateway . . . . . . . . . :
   DHCP Server . . . . . . . . . . . : 192.168.136.254
   DHCPv6 IAID . . . . . . . . . . . : 721440854
   DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-2B-B8-05-2E-08-97-98-BC-C3-01
   Primary WINS Server . . . . . . . : 192.168.136.2

Conclusion

In this tutorial, we discussed how we can use the Windows Network Shell to quickly configure various network properties such as IP address, DNS Servers and more.

We hope you enjoyed this tutorial. Please feel free to leave us a comment down below and let us know what you think.

Thank you for reading.

Some Cool Stuff to Check Out

How to Find the Wi-Fi Password Using CMD in Windows
In this article, you learn how to use the command prompt to get the Wi-Fi password to avoid resetting the passwords just because you forgot it.
How to hide your username in the Windows login
In this article, we will explore how you can hide your username and other personal info at your Windows login screen.

If you enjoy our content, please consider buying us a coffee to support our work:

Share
Comments
More from GeekBits

Join us at GeekBits

Join our members and get a currated list of awesome articles each month.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to GeekBits.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.