Windows – netsh – Change you IP address via the CLI

Netsh.exe is a network administration tool that allows you to configure and monitor Windows-based computers at a command prompt. With the Netsh.exe tool, you can direct the context commands you enter to the appropriate helper, and the helper then carries out the command.

Setting you IP address

Below is the syntax for setting the IP address for your wireless connection and adding to DNS servers. Note you can get the name of your interface from the IP config command.

netsh interface ip set address name=”Wireless Network Connection 3″ static [ip] [netmask] [gw]
netsh interface ip set dns “Wireless Network Connection 3”  static [dns server ip]
netsh interface ip add dns “Wireless Network Connection 3” [dns server ip] index=2

Saving your configuration and importing

To export your configuration

netsh -c interface dump > c:\location1.txt

To import your configuration

netsh -f interface dump > c:\location1.txt

Windows firewall

Below shows the syntax for opening a port, showing your firewall state, and disabling the firewall

netsh firewall set portopening tcp 445 smb enable
netsh firewall show state
netsh firewall set opmode disable


netsh diag GUI


Below will connect to the default incoming and outgoing mail servers then drop the connection. Easier for customers than trying to telnet to the mail server ports.

netsh diag connect mail

Reset all IP protocol stack configurations on your interface and send the output to a log file.

netsh int ipv4 reset resetlog.txt


Rick Donato

Want to become a Windows expert?

Here is our hand-picked selection of the best courses you can find online:
Windows Server 2019 Administration course
Windows 10 Troubleshooting course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial