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

What Young Riders Should Know About Moving Their Motorcycles Across Cities

What Young Riders Should Know About Moving Their Motorcycles Across Cities

Long-distance travel can involve heavy traffic, changing weather conditions, and rider fatigue. If you are also dealing with the responsibilities of moving home, such as packing belongings or coordinating accommodation, a long ride may add unnecessary pressure to an already busy schedule.

Solving Microsoft Teams Shortcut Error Not Opening

Solving Microsoft Teams Shortcut Error Not Opening

Tired of Microsoft Teams shortcut error preventing you from opening the app? Follow our expert, step-by-step guide with the latest fixes for instant resolution. Works on Windows, Mac & web – no tech skills needed!

Solving Microsoft Teams Task Management Sync Error

Solving Microsoft Teams Task Management Sync Error

Tired of Microsoft Teams Task Management Sync Error halting your workflow? Follow our proven, step-by-step fixes to resolve sync issues fast and restore seamless task collaboration. No tech expertise needed!

Troubleshooting Microsoft Teams Wiki Error Formatting

Troubleshooting Microsoft Teams Wiki Error Formatting

Struggling with Microsoft Teams Wiki Error Formatting? This step-by-step guide reveals proven fixes for common wiki tab issues, ensuring smooth editing and collaboration in Teams. Get back to productive wikis fast!

How to Fix Microsoft Teams Installation Error for Linux

How to Fix Microsoft Teams Installation Error for Linux

Struggling with Microsoft Teams installation error on Linux? Discover step-by-step fixes for Ubuntu, Fedora & more. Resolve dependency issues, crashes, and errors quickly with our ultimate guide. Get Teams running smoothly today!

Solving Microsoft Teams Error Page Not Loading

Solving Microsoft Teams Error Page Not Loading

Struggling with Microsoft Teams "Error Page" not loading? Get step-by-step fixes for desktop, web, and mobile. Solve Microsoft Teams Error Page issues quickly and resume seamless teamwork today.

Solving Microsoft Teams Error Screenshot Issues

Solving Microsoft Teams Error Screenshot Issues

Tired of Microsoft Teams "Error Screenshot" blocking your workflow? Get proven, step-by-step solutions to resolve screenshot errors in Teams instantly and boost productivity. No tech skills needed!

How to Fix Microsoft Teams Error U User

How to Fix Microsoft Teams Error U User

Tired of Microsoft Teams "Error U" User blocking your chats? Get proven, step-by-step fixes to clear cache, reset, and restore seamless collaboration instantly.

Where are Microsoft Teams Registry Keys Located on Windows 11?

Where are Microsoft Teams Registry Keys Located on Windows 11?

Unlock the precise locations of Microsoft Teams registry keys on Windows 11. Step-by-step guide to find, access, and safely tweak them for optimal performance and troubleshooting. Essential for IT pros and Teams enthusiasts.

How to Fix Microsoft Teams Training Error Video Lag

How to Fix Microsoft Teams Training Error Video Lag

Tired of Microsoft Teams "Training Error" Video Lag ruining your meetings? Follow our step-by-step guide with the latest fixes for smooth video calls—no more frustration!