Networking/Computing Tips/Tricks

Rate this content:
5 of 5 - 2 votes
Thank you for rating this article.

What is Netsh?

Netsh is a Microsoft Windows command-line shell/scripting utility originally introduced in Windows 2000 that allows you to, either locally or remotely, display or modify the network configuration of a computer that is currently running.

Netsh also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer.

Netsh can also save a configuration script in a text file for archival purposes or to help you configure other servers.

How does it work?

Netsh interacts with other Windows operating system components using dynamic-link library (DLL) files. Each Netsh helper DLL provides an extensive set of features called a context, which is a group of commands specific to a networking component. These contexts extend the functionality of netsh by providing configuration and monitoring support for one or more services, utilities, or protocols. For example, Dhcpmon.dll provides netsh the context and set of commands necessary to configure and manage DHCP servers.

To run a netsh command, you must start netsh from the Cmd.exe prompt and change to the context that contains the command you want to use. The contexts that are available to you depend on which networking components you have installed.

For example, if you type dhcp at the Netsh command prompt, you change to the DHCP context, but if you do not have DHCP installed the following message appears:

The following command was not found: dhcp.

If you run “netsh /?” in your operating system, you will get the different contexts supported by your system. For example, Windows XP has “routing” listed as a context and Windows Server 2008 does not.  Here are some of the contexts you might see:

[older version of Windows]


[newer version of Windows]

2019 09 26 7 25 38

Some Clever things You Can Do With Netsh:

  • Show your computer's IP address:
    netsh interface ip show config
  • Set an interface to use DHCP for its IP address configuration:  
    netsh interface ip set address name="Local Area Connection" source=dhcp
  • Set an interface to use a static IP address for its IP address configuration: 
    netsh interface ip set address "Local Area connection" static 1
  • Or, add a DNS Server entry: 
    netsh interface ip add dnsserver "Local Area Connection"
  • With netsh, you can quickly and easily open a port on your firewall if you know the right command. Here is an example of opening port 445:
    netsh firewall set portopening tcp 445 smb enable
  • With netsh, exporting and importing your IP address configuration is easy – unlike in the GUI interface. To export your configuration just do:
    netsh –c interface dump > nettest.txt
    Later on this machine or on a different machine, you could import this configuration with:
    netsh –f nettest.txt
  • There are a number of things you can do with netsh to troubleshoot and reset your TCP/IP network interface. Here are some examples:
    • Reset all IP protocol stack configurations on your interface and send the output to a log file:
      netsh int ipv4 reset myresetlog.txt
    • Install the TCP/IP protocol:
      netsh int ipv4 install
    • UnInstall the TCP/IP protocol:
      netsh int ipv4 uninstall
  • You can also configure the traditional Windows firewall. Here are some examples:
    • Show all firewall rules:
      netsh advfirewall firewall show rule name=all
    • Delete an inbound advanced firewall rule for port 21:
      netsh advfirewall firewall delete name rule name=all protocol=tcp localport=21
    • Export Windows Advanced Firewall settings:
      netsh advfirewall export “c:\myfirewall.wfw”
    • Perhaps the most common command you might use is the command to enable or disable your Windows firewall, like this:
      netsh firewall set opmode disable ornetsh firewall set opmode enable
  • You can now configure wireless networking context settings using netsh in Windows Server 2008 and Windows Vista/7. Here are some examples:
    • Connect to an already defined wireless network:
      netsh wlan connect ssid=”mySSID” name=”WLAN-Profil1”
    • Show your current wireless settings:
      netsh wlan show settings
    • Add an already exported wireless network profile:
      netsh wlan add profile filename="Wireless Network Connection-BOW.xml"

If any of the commands above are successful, you should get a response of “Ok.”


If you would like to see some Netsh command used for IPv6, check out this article.

I hope you find this article and its content helpful.  Comments are welcomed below.  If you would like to see more articles like this, please support us by clicking the patron link where you will receive free bonus access to courses and more, or simply buying us a cup of coffee!, and all comments are welcome! 

Add comment


Did you learn something?
Did I save you time? 

Buy me a coffeeBuy me a coffee!

Find by Tag

5G Networks 6LoWLAN 6LoWPAN 802.11 802.11ah 802.11ax 802.11ay 802.11az ACL Addressing Analysis Ansible Architecture ARP Assessment AToM Backup Bandwidth BGP Bibliography Biography Briefings CBRS CellStream Cellular Central Office Cheat Sheet Chrome Cisco Clock Cloud Computer Consulting CPI Data Center Data Networking Decryption DHCPv4 DHCPv6 Display Filter DNS Documentation ECMP EIGRP Ethernet Flipping the Certification Model Follow Me Fragmentation Git GNS3 Google GQUIC Hands-On History Home Network HTTPS ICMP ICMPv6 IEEE 802.11p IEEE 802.15.4 In A Day Internet IOS Classic IoT IPv4 IPv6 L2 Switch L2VPN L3VPN LDP Learning Services Linux LLN Logging LoL M-BGP MAC MAC OSx Macro Microsoft mininet Monitoring Monitor Mode MPLS Multicast Name Resolution Netflow NetMon netsh Networking Network Science nmap Npcap nslookup Online Learning Online School OpenFlow OSPF OSPFv2 OSPFv3 OSX Parrot Passwords pcap pcap-ng PIM Ping Policy Port Mirror POTS POTS to Pipes PPP Profile Profiles Programming Project Management Python QoS QUIC Requirements RFC RIP Routing RPL RSVP SAS SDN Security Self Certification Service Provider Small Business Smartport SONET Span Port SSH SSL Subnetting T-Shark TCP TCP/IP Telco Telecom 101 Telecommunications Telnet Terminal TLS Tools Traceroute Traffic Analysis Traffic Engineering Training Travel Troubleshooting Tunnel Utility Video Virtualbox Virtualization Voice VoIP VXLAN Webex Wi-Fi Wi-Fi 4 Wi-Fi 5 Wi-Fi 6 Wi-Fi 6/6E Windows Wireless Wireless 5G Wireshark Wireshark Tip WLAN ZigBee Zoom

Twitter Feed