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.

Sign up and earn $1000 a day ⋙

Leave a Comment

How to regain access to hard drive, fix error of not being able to open hard drive

How to regain access to hard drive, fix error of not being able to open hard drive

In this article, we will guide you how to regain access to your hard drive when it fails. Let's follow along!

How to use dental floss

How to use dental floss

Dental floss is a common tool for cleaning teeth, however, not everyone knows how to use it properly. Below are instructions on how to use dental floss to clean teeth effectively.

How to gain muscle according to experts

How to gain muscle according to experts

Building muscle takes time and the right training, but its something anyone can do. Heres how to build muscle, according to experts.

The Best Diets for Heart Health

The Best Diets for Heart Health

In addition to regular exercise and not smoking, diet is one of the best ways to protect your heart. Here are the best diets for heart health.

How to cure insomnia for pregnant women in the last 3 months

How to cure insomnia for pregnant women in the last 3 months

The third trimester is often the most difficult time to sleep during pregnancy. Here are some ways to treat insomnia in the third trimester.

Scientifically Proven Ways to Automatically Burn Calories

Scientifically Proven Ways to Automatically Burn Calories

There are many ways to lose weight without changing anything in your diet. Here are some scientifically proven automatic weight loss or calorie-burning methods that anyone can use.

All about iOS 26

All about iOS 26

Apple has introduced iOS 26 – a major update with a brand new frosted glass design, smarter experiences, and improvements to familiar apps.

Yoga exercises to treat insomnia

Yoga exercises to treat insomnia

Yoga can provide many health benefits, including better sleep. Because yoga can be relaxing and restorative, its a great way to beat insomnia after a busy day.

What is the flower of the other shore? Meaning and legend of the flower of the other shore

What is the flower of the other shore? Meaning and legend of the flower of the other shore

The flower of the other shore is a unique flower, carrying many unique meanings. So what is the flower of the other shore, is the flower of the other shore real, what is the meaning and legend of the flower of the other shore?

Healthy snacks that help you lose weight

Healthy snacks that help you lose weight

Craving for snacks but afraid of gaining weight? Dont worry, lets explore together many types of weight loss snacks that are high in fiber, low in calories without making you try to starve yourself.

What to do when you have trouble sleeping?

What to do when you have trouble sleeping?

Prioritizing a consistent sleep schedule and evening routine can help improve the quality of your sleep. Heres what you need to know to stop tossing and turning at night.

How to add a printer to Windows 10

How to add a printer to Windows 10

Adding a printer to Windows 10 is simple, although the process for wired devices will be different than for wireless devices.

The most commonly deficient nutrients in the diet

The most commonly deficient nutrients in the diet

Diet is important to our health. Yet most of our meals are lacking in these six important nutrients.

How to get beautiful nails quickly

How to get beautiful nails quickly

You want to have a beautiful, shiny, healthy nail quickly. The simple tips for beautiful nails below will be useful for you.

The best laptops for students in 2025

The best laptops for students in 2025

Students need a specific type of laptop for their studies. It should not only be powerful enough to perform well in their chosen major, but also compact and light enough to carry around all day.