Here we shall show you how you can configure your system’s IP address directly through the command line interface on your Windows 10 platform. It is very less time consuming and can be done in a few steps. The IP address is a unique identifier of your machine that lets every other component on the network know where the packets need to be routed to. Since it is unique, it cannot conflict with another IP address on the same network. You can manage your IP address by both the Command Prompt and the PowerShell, which shall be discussed further in the article. If you are looking for a way to instantly switch between different network profiles, you can make use of NetSetMan 5.
How to check Interface Index using PowerShell
The Interface Index is a unique number assigned to either a physical or virtual networking port. Each port is assigned a number that is used to address the respective port on the machine. For example, if there are 5 different networking adapters on a computer, each one would have its own Interface Index. To check the associated Interface Index for each, run the following command in PowerShell with administrative privileges: In the example above, the “ifIndex” is identified as the Interface Index. Note that the ports are repeated as the first half represents IPv6, while the 2nd half represents IPv4 configuration. Nonetheless, the Interface Indexes of the same ports are the same. Note down the associated Interface Indexes as they will be required when assigning static IPs through PowerShell.
How to set static IP address using Command Prompt
These commands are relatively easier with the Command Prompt when compared with PowerShell. You can change the IP address of your computer using this quick command. Launch the Command Prompt with administrative privileges and then use the command below to assign the desired IP address configuration: In the above command, you need to place the information according to your requirement. Replace NameOfPort with the alias name of the network adapter you wish to set the IP of. Also, replace [IP address] with the IP address of the port you wish to assign, replace [Subnet mask] with its subnet, and replace [Default gateway] with the gateway of the adapter. Here is an example: Since the name of my port is “Ethernet,” entering the command above would result in the following configuration:
How to set DNS address using Command Prompt
As you may have noticed above, we did not set up the DNS. This is because you need to enter a separate command to configure the DNS, which is as below: This will set the first DNS entry as 8.8.8.8. Note that this will only occur if the port can communicate with the DNS. Else it will throw an exception. The above command would result in something like this: To change the second DNS server, use the following command: Remember to change the port name, IP address, gateway, and subnet mask according to your requirement. Each time you need to switch between your IPs and DNSs, use these commands, and it will automatically overwrite the previous entering.
How to set static IP address using PowerShell
Although the PowerShell command lines are more complex than those of the Command Prompt, they also offer more parameters to be addressed. However, we will try and keep it as plain and simple as possible. Before we proceed further, you need to understand some terms to enter the correct parameters. Below are a few arguments and their descriptions used in PowerShell to set static IPs and DNS entries.ArgumentDescriptionInterfaceIndexA unique number is assigned to each portPrefixLengthSubnet maskAddressFamilyEither IPv4 or IPv6AsJobRun task in background Now, modify the following command according to your needs, launch Windows PowerShell with administrative privileges and enter the command: Note that we determined the correct Interface Index using the command we had discussed earlier in the article. This is what the IP configuration of the port would look like after running the command above:
How to set DNS address using PowerShell
You can also use PowerShell to assign DNS addresses as well quickly. In the example below, we have assigned both the primary and the secondary DNS addresses to our port simultaneously. You may repeatedly use these commands in PowerShell to overwrite new IP address, subnet mask, gateway and DNS entries of any network port you want on your PC.
Closing words
Now you do not need to worry about switching from one network to another. You can make the process even quicker by saving the respective IP configuration on your PC and copy-pasting it to the command line when required to switch. If, however, you run into a problem associated with your computer network, you may use this guide to reset the TCP/IP stack. Also see:
How to Change Network Priority in Windows (Ethernet + Wifi Networks)How To Find And Close Listening Ports In Windows 10How to Set Up Remote Desktop Over the Internet on Windows 103 Ways to Access Network Path Using Command Line in Windows 104 Ways To Forget Wi-Fi Network Profile In Windows 11/10