


How to use the netsh command for network configuration in Windows
Aug 01, 2025 am 03:55 AMTo use netsh, open Command Prompt as Administrator and type netsh to enter the netsh shell or run commands directly like netsh interface ip show config. 2. For IP configuration, set a static IP with netsh interface ip set address "Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1, switch to DHCP using netsh interface ip set address "Ethernet" dhcp, and configure DNS with netsh interface ip set dns "Ethernet" static 8.8.8.8 or set it to automatic with dhcp. 3. To reset network components, use netsh int ip reset C:\resetlog.txt to reset TCP/IP stack and netsh winsock reset to clear Winsock catalog, followed by a system restart. 4. Manage Wi-Fi networks using netsh wlan: show available networks with netsh wlan show networks, list saved profiles with netsh wlan show profiles, view a Wi-Fi password via netsh wlan show profile name="YourWiFiName" key=clear, export a profile with netsh wlan export profile name="YourWiFiName" folder=C:\, and delete a profile using netsh wlan delete profile name="OldNetwork". 5. Control Windows Firewall with netsh advfirewall: disable it using netsh advfirewall set allprofiles state off (not recommended), enable it with netsh advfirewall set allprofiles state on, and allow a program through firewall by adding a rule such as netsh advfirewall firewall add rule name="Allow Chrome" dir=in program="C:\Program Files\Google\Chrome\Application\chrome.exe" action=allow. 6. For remote configuration, run netsh -r \\RemotePC -u AdminUser -p Password interface ip show config, though PowerShell with WinRM is now preferred. Always run Command Prompt as Administrator, verify interface names using netsh interface show interface, back up configurations using netsh dump > C:\backup_network.cfg, restore them with netsh exec C:\backup_network.cfg, and use resets cautiously.
The netsh
command in Windows is a powerful built-in tool that lets you configure, monitor, and troubleshoot network settings from the command line—either locally or remotely. Whether you're resetting network components, changing IP addresses, or diagnosing connectivity issues, netsh
can handle it all. Here’s how to use it effectively for common network configuration tasks.

1. Accessing and Navigating netsh
To use netsh
, open Command Prompt as an administrator:
- Press
Win X
and select Command Prompt (Admin) or Windows Terminal (Admin). - Type
netsh
and press Enter.
This drops you into the netsh>
prompt, where you can navigate different contexts like interface
, wlan
, firewall
, etc.

You can also run commands directly without entering the netsh shell:
netsh interface ip show config
Use ?
or help
at any time to see available commands.

2. Configuring IP Addresses (DHCP or Static)
One of the most common uses of netsh
is managing IP configurations.
Set a Static IP Address
Replace the values with your network settings:
netsh interface ip set address "Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1
"Ethernet"
: Name of your network interface (usenetsh interface show interface
to list them).static
: Indicates static IP assignment.- IP, subnet mask, and gateway follow.
Set IP to Use DHCP
To revert to automatic IP assignment:
netsh interface ip set address "Ethernet" dhcp
Set DNS Servers
Set DNS to automatic (via DHCP):
netsh interface ip set dns "Ethernet" dhcp
Set a manual DNS server (e.g., Google DNS):
netsh interface ip set dns "Ethernet" static 8.8.8.8
Add a secondary DNS:
netsh interface ip add dns "Ethernet" 8.8.4.4 index=2
3. Resetting Network Components
If you're having network issues, resetting TCP/IP stack or Winsock can help.
Reset TCP/IP Stack
netsh int ip reset C:\resetlog.txt
This resets the IP configuration to default and logs actions to the specified file.
Reset Winsock
netsh winsock reset
This clears Winsock catalog to fix connectivity issues, especially after malware or misconfigurations.
?? Note: You’ll need to restart your computer after running these reset commands.
4. Managing Wireless Networks (Wi-Fi)
netsh wlan
lets you view, export, and manage Wi-Fi profiles.
Show Available Wi-Fi Networks
netsh wlan show networks
List Saved Wi-Fi Profiles
netsh wlan show profiles
Show Password for a Wi-Fi Network
netsh wlan show profile name="YourWiFiName" key=clear
Look for the Key Content field under Security settings to see the password.
Export a Wi-Fi Profile
Useful for backing up or transferring Wi-Fi settings:
netsh wlan export profile name="YourWiFiName" folder=C:\
This saves an .xml
file you can import on another machine.
Delete a Wi-Fi Profile
netsh wlan delete profile name="OldNetwork"
5. Firewall Management
You can control Windows Firewall using netsh advfirewall
.
Turn Off Firewall (Not Recommended)
netsh advfirewall set allprofiles state off
Turn On Firewall
netsh advfirewall set allprofiles state on
Allow a Program Through Firewall
netsh advfirewall firewall add rule name="Allow Chrome" dir=in program="C:\Program Files\Google\Chrome\Application\chrome.exe" action=allow
6. Remote Configuration (Advanced)
You can run netsh
commands on a remote machine if you have admin access:
netsh -r \\RemotePC -u AdminUser -p Password interface ip show config
Note: This method is older; PowerShell with WinRM is now preferred for remote management.
Tips and Best Practices
Always run Command Prompt as Administrator for configuration changes.
Double-check interface names using
netsh interface show interface
.Use
netsh dump
to export current network configuration to a script:netsh dump > C:\backup_network.cfg
You can later reapply it with:
netsh exec C:\backup_network.cfg
Be cautious with resets—only use them when necessary.
Basically, netsh
is a versatile tool that gives you deep control over Windows networking. While newer tools like PowerShell (NetTCPIP
, NetAdapter
) are replacing some functions, netsh
remains widely used—especially in scripts and troubleshooting scenarios.
The above is the detailed content of How to use the netsh command for network configuration in Windows. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

If you're having trouble reading your desktop icons' text or simply want to personalize your desktop look, you may be looking for a way to change the font color on desktop icons in Windows 11. Unfortunately, Windows 11 doesn't offer an easy built-in

Fixed Windows 11 Google Chrome not opening Google Chrome is the most popular browser right now, but even it sometimes requires help to open on Windows. Then follow the on-screen instructions to complete the process. After completing the above steps, launch Google Chrome again to see if it works properly now. 5. Delete Chrome User Profile If you are still having problems, it may be time to delete Chrome User Profile. This will delete all your personal information, so be sure to back up all relevant data. Typically, you delete the Chrome user profile through the browser itself. But given that you can't open it, here's another way: Turn on Windo

When Windows cannot detect a second monitor, first check whether the physical connection is normal, including power supply, cable plug-in and interface compatibility, and try to replace the cable or adapter; secondly, update or reinstall the graphics card driver through the Device Manager, and roll back the driver version if necessary; then manually click "Detection" in the display settings to identify the monitor to confirm whether it is correctly identified by the system; finally check whether the monitor input source is switched to the corresponding interface, and confirm whether the graphics card output port connected to the cable is correct. Following the above steps to check in turn, most dual-screen recognition problems can usually be solved.

Mini PCs have undergone

Have problems uploading files in Google Chrome? This may be annoying, right? Whether you are attaching documents to emails, sharing images on social media, or submitting important files for work or school, a smooth file upload process is crucial. So, it can be frustrating if your file uploads continue to fail in Chrome on Windows PC. If you're not ready to give up your favorite browser, here are some tips for fixes that can't upload files on Windows Google Chrome 1. Start with Universal Repair Before we learn about any advanced troubleshooting tips, it's best to try some of the basic solutions mentioned below. Troubleshooting Internet connection issues: Internet connection

When encountering the problem of printing task stuck, clearing the print queue and restarting the PrintSpooler service is an effective solution. First, open the "Device and Printer" interface to find the corresponding printer, right-click the task and select "Cancel" to clear a single task, or click "Cancel all documents" to clear the queue at one time; if the queue is inaccessible, press Win R to enter services.msc to open the service list, find "PrintSpooler" and stop it before starting the service. If necessary, you can manually delete the residual files under the C:\Windows\System32\spool\PRINTERS path to completely solve the problem.

To run command prompts as administrator, the most direct way is to search through the Start menu and right-click "Run as administrator"; secondly, use the Win X shortcut menu to select "Command Prompt (Administrator)" or "Windows Terminal (Administrator)"; you can also open the run window through Win R and enter cmd and press Ctrl Shift Enter to force running as administrator; in addition, you can set shortcut properties to achieve automatic running as administrator. All the above methods require administrator permission and confirmation through UAC. Pay attention to security risks during operation.
