Configure TCP/IP from the command line

To configure TCP/IP like IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe or Netsh command .

Netsh.exe is a command-line utility that allows you to display or change the network configuration (both local and remote) of a currently running computer. Netsh.exe also provides a scripting feature that allows you to run a group of commands in batch mode against a specified computer. Netsh.exe can also save a configuration script to a text file for archival purposes or to help you configure other servers.

Netsh.exe is available on Windows 2000 and Windows Server 2003 and above. If you are using Windows 10, Windows Server 2016 you can still use the Netsh command normally.

You can use the Netsh.exe tool to perform the following tasks:

  • Interface configuration
  • Configure routing protocols.
  • Filter configuration.
  • Configure routes.
  • Configuring remote access for remote routers depends on Windows, these routers are running on the Routing and Remote Access Server service.
  • Displays the current running router configuration on any computer
  • Use the script feature to run a series of commands in batch mode against a specified router.

What can you do with Netsh.exe

With netsh.exe you can easily view your TCP/IP settings. Type the following command into cmd:

netsh interface ip show config

With Netsh.exe, you can easily configure your computer's IP address and other related TCP/IP settings. For example:

The following command configures an interface named Local Area Connection with a static IP address of 192.168.0.100, its subnet mask of 255.255.255.0, and its default gateway of 192.168.0.1:

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

Other TCP/IP settings:

netsh interface ip set dns "Local Area Connection" static 192.168.0.100 index=1
netsh interface ip set dns "Local Area Connection" static 192.168.0.101 index=2
netsh interface ip set wins "Local Area Connection" static 192.168.0.100

Netsh.exe is also useful in situations such as when you have a laptop that needs to be re-located between 2 or more offices, while still maintaining a static and specified IP address configuration. With Netsh.exe, you can easily save and restore the appropriate network configuration.

First, connect your laptop to location #1, then manually configure the required settings (like IP address, Subnet Mask, Default Gateway, DNS and WINS).

Now, you need to export your current IP settings to a text file. Use the following command:

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

When you get to position #2, do the same, just keep the new settings on a different file:

netsh -c interface dump > c:'location2.txt

You can continue with whatever positions you need, but we'll keep it simple and just use 2 as an example.

Now, any time you need to import your IP settings and change it between #1 and #2, just type the following command into cmd:

netsh -f c:'location1.txt

or:

netsh -f c:'location2.txt

You can also use the EXEC parameter instead of -F :

netsh exec c:'location2.txt

Netsh.exe can also be used to configure your Nic to automatically obtain an IP address from a DHCP server:

netsh interface ip set address "Local Area Connection" dhcp

Do you want to configure DNS and WINS addresses from the command line? You can do this. See the example below for DNS:

netsh interface ip set dns "Local Area Connection" static 192.168.0.200

and this for WINS:

netsh interface ip set wins "Local Area Connection" static 192.168.0.200

Or if you prefer, you can configure the NIC to automatically retrieve its DNS settings.

As you can see, Netsh.exe has a lot of very useful features. In addition, it has many other valuable options waiting for you to explore.

Leave a Comment

Solving Microsoft Teams OneDrive Error File Sync

Solving Microsoft Teams OneDrive Error File Sync

Tired of Microsoft Teams OneDrive Error blocking file sync? Follow our step-by-step guide to solve Microsoft Teams "OneDrive Error" File Sync issues quickly. Proven fixes for smooth collaboration in Teams channels. Get your files syncing error-free today!

How to Fix Microsoft Teams Workflows and Power Automate Errors

How to Fix Microsoft Teams Workflows and Power Automate Errors

Tired of Microsoft Teams workflows and Power Automate errors halting your productivity? Get step-by-step solutions to common issues like authentication failures, timeouts, and flow errors. Fix them in minutes and automate effortlessly!

Troubleshooting Microsoft Teams Download Error on Macbook

Troubleshooting Microsoft Teams Download Error on Macbook

Facing Microsoft Teams "Download Error" on MacBook? Discover proven troubleshooting steps to resolve download failures quickly, from cache clears to reinstalls, and get back to smooth teamwork.

Troubleshooting Microsoft Teams Where is Teams Folder Error

Troubleshooting Microsoft Teams Where is Teams Folder Error

Tired of the frustrating Microsoft Teams "Where is Teams" Folder Error? Discover proven, step-by-step troubleshooting fixes to resolve it quickly and restore smooth teamwork. Latest methods included!

How to Fix Microsoft Teams JavaScript Error on Desktop App

How to Fix Microsoft Teams JavaScript Error on Desktop App

Frustrated by Microsoft Teams JavaScript Error on desktop app? Discover proven steps to fix it fast: clear cache, update, reset, and reinstall. Get back to seamless collaboration in minutes!

How to Fix Microsoft Teams Guest Login Error

How to Fix Microsoft Teams Guest Login Error

Struggling with Microsoft Teams "Guest Login" Error? Discover step-by-step fixes, from quick cache clears to admin settings, to resolve guest access issues fast and collaborate seamlessly. Updated with the latest tips!

How to Fix Microsoft Teams For PC Download Error

How to Fix Microsoft Teams For PC Download Error

Tired of the Microsoft Teams "For PC" download error blocking your work? Follow our proven, step-by-step guide to resolve it quickly and get Teams running smoothly on your PC today.

Solving Microsoft Teams Windows 7 Login Error

Solving Microsoft Teams Windows 7 Login Error

Struggling with Microsoft Teams "Windows 7" login error? Discover step-by-step fixes for this frustrating issue on Windows 10/11. Clear cache, edit registry, and more – get back to seamless collaboration today!

How to Fix Microsoft Teams Error Code 0x80070005 (2026 Guide)

How to Fix Microsoft Teams Error Code 0x80070005 (2026 Guide)

Tired of Microsoft Teams Error Code 0x80070005 blocking your meetings? Follow this 2026 guide with step-by-step fixes for access denied issues. Get Teams running smoothly in minutes!

How to Install the Microsoft Teams Add-in for Outlook 2026

How to Install the Microsoft Teams Add-in for Outlook 2026

Master the installation of the Microsoft Teams Add-in for Outlook 2026 effortlessly. Boost your productivity with seamless scheduling and meetings. Follow our proven, up-to-date steps for instant success!

How to Fix Microsoft Teams License Error 2026

How to Fix Microsoft Teams License Error 2026

Struggling with Microsoft Teams "License Error" 2026? Discover proven, step-by-step solutions to resolve it fast. Clear cache, check licenses, and get back to seamless collaboration—no IT help needed!

The Best Exercises for 50+

The Best Exercises for 50+

Whether youre in your 50s, 60s, or even 70s, its not too late to prioritize your health and put yourself first. Here are the best exercises for people 50 and older.

Solving Microsoft Teams Error Caa50024 on Windows 10/11

Solving Microsoft Teams Error Caa50024 on Windows 10/11

Struggling with Microsoft Teams Error Caa50024 on Windows 10/11? Follow our step-by-step fixes to resolve crashes and launch issues quickly. Latest proven solutions for seamless teamwork.

How to Fix Microsoft Teams Login Error AADSTS50011

How to Fix Microsoft Teams Login Error AADSTS50011

Stuck with Microsoft Teams login error AADSTS50011? Discover proven, step-by-step fixes to resolve the reply URL mismatch issue and log in seamlessly. No tech skills needed!

How to Fix Microsoft Teams Win 7 Compatibility Error

How to Fix Microsoft Teams Win 7 Compatibility Error

Tired of the frustrating Microsoft Teams "Win 7" Compatibility Error blocking your meetings? Get instant fixes with our step-by-step guide, including workarounds for older Windows versions. Resolve it now and stay connected!