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

Difference between regular TV and Smart TV

Difference between regular TV and Smart TV

Smart TVs have really taken the world by storm. With so many great features and the ability to connect to the Internet, technology has changed the way we watch TV.

Why doesnt the freezer have a light but the refrigerator does?

Why doesnt the freezer have a light but the refrigerator does?

Refrigerators are familiar appliances in families. Refrigerators usually have 2 compartments, the cool compartment is spacious and has a light that automatically turns on every time the user opens it, while the freezer compartment is narrow and has no light.

2 Ways to Fix Network Congestion That Slows Down Wi-Fi

2 Ways to Fix Network Congestion That Slows Down Wi-Fi

Wi-Fi networks are affected by many factors beyond routers, bandwidth, and interference, but there are some smart ways to boost your network.

How to Downgrade from iOS 17 to iOS 16 without Losing Data using Tenorshare Reiboot

How to Downgrade from iOS 17 to iOS 16 without Losing Data using Tenorshare Reiboot

If you want to go back to stable iOS 16 on your phone, here is the basic guide to uninstall iOS 17 and downgrade from iOS 17 to 16.

What happens to the body when you eat yogurt every day?

What happens to the body when you eat yogurt every day?

Yogurt is a great food. Is it good to eat yogurt every day? What will happen to your body when you eat yogurt every day? Let's find out together!

Which type of rice is best for health?

Which type of rice is best for health?

This article discusses the most nutritious types of rice and how to maximize the health benefits of whichever rice you choose.

How to wake up on time in the morning

How to wake up on time in the morning

Establishing a sleep schedule and bedtime routine, changing your alarm clock, and adjusting your diet are some of the measures that can help you sleep better and wake up on time in the morning.

Rent Please! Landlord Sim Tips for Beginners

Rent Please! Landlord Sim Tips for Beginners

Rent Please! Landlord Sim is a simulation mobile game on iOS and Android. You will play as a landlord of an apartment complex and start renting out an apartment with the goal of upgrading the interior of your apartments and getting them ready for rent.

Latest Bathroom Tower Defense Codes and How to Enter Codes

Latest Bathroom Tower Defense Codes and How to Enter Codes

Get Bathroom Tower Defense Roblox game codes and redeem them for exciting rewards. They will help you upgrade or unlock towers with higher damage.

Structure, symbols and operating principles of transformers

Structure, symbols and operating principles of transformers

Let's learn about the structure, symbols and operating principles of transformers in the most accurate way.

4 Ways AI Is Making Smart TVs Better

4 Ways AI Is Making Smart TVs Better

From better picture and sound quality to voice control and more, these AI-powered features are making smart TVs so much better!

Why ChatGPT is better than DeepSeek

Why ChatGPT is better than DeepSeek

DeepSeek initially had high hopes. As an AI chatbot marketed as a strong competitor to ChatGPT, it promised intelligent conversational capabilities and experiences.

Meet Fireflies.ai: The Free AI Secretary That Saves You Hours of Work

Meet Fireflies.ai: The Free AI Secretary That Saves You Hours of Work

It's easy to miss important details when you're jotting down other essentials, and trying to take notes while chatting can be distracting. Fireflies.ai is the solution.

How to raise Axolotl Minecraft, tame Minecraft Salamander

How to raise Axolotl Minecraft, tame Minecraft Salamander

Axolot Minecraft will be a great assistant for players when operating underwater if they know how to use them.

A Quiet Place: The Road Ahead PC Game Configuration

A Quiet Place: The Road Ahead PC Game Configuration

A Quiet Place: The Road Ahead's configuration is rated quite highly, so you will need to consider the configuration before deciding to download.