You may know how to change IP address via GUI. It’s pretty easy. Just go to Control panel > network and internet, selecting the IPv4 Properties and change the IP address. This whole process will take around a minute to do so. But what if you have to do it on multiple systems and repeat all these steps multiple times. It will become really tiresome. PowerShell can do this tedious task very easily.
PowerShell may sound difficult to use and you may hesitate to work on it but it has several unique features.
With PowerShell, you can gather information, change system settings and automate most anything on Windows. It’s more powerful than Cmd and offers more flexibility. Tasks done with PowerShell does not only automated but they also save time.
To Open PowerShell, type PowerShell in the search bar of your Windows 10 computer, then press Ctrl+Shift+Enter to launch it with administrator privileges.
To see the current IP configuration, type Get-NetIPAddress in PowerShell
Get-NetIPAddress gives IP address information with prefix length and address family.
Alternatively, you can type Get-NetIPConfiguration to get some advanced details. It gives IP address information along with its default gateway, DNS information and Interface index.
From Get-NetIPConfiguration Result, note down the index number of the adapter for which you want to change IP address.
To specifically get the Interface index, type
Set a new IP address using PowerShell
All of the above commands are used to view current configurations. To set a new IP address, execute below command. Replace xxx.xxx.xxx.xxx with your own IP address.
Suppose we have the following required configurations:
Replace the command parameters with your own addresses.
Note that the prefix length specifies the subnet mask of IP address.
Set a New DNS Servers Address
Up till now, we have configured IP address, subnet mask, and Default-gateway successfully. Now one thing is missing that is DNS server address. to set new DNS server address, type the command in below syntax.
Replace xxx.xxx.xxx.xxx with your required primary and secondary DNS server addresses.
If you want to remove the IP address with PowerShell, use the following command
As you can see, it is relatively straightforward to configure TCP/IP through PowerShell. The techniques that I have shown you tend to be most useful when you need to configure multiple machines.
If you are experiencing trouble with your network connection and have it configured to DHCP then, figuring out your IP address can be quite a task. Using Static IP Address helps avert IP address conflicts between networked devices and enables their easy management. This article will show you how to assign a static IP address on a Windows 10 computer.
Assign a static IP address in Windows 10
In most cases, the IP addresses for PCs or computers are automatically configured to Dynamic Host Configuration Protocol (DHCP) by the respective router. This is useful as the devices connect to your network instantly. You save the trouble of manually configuring the IP address for each new device yourself. However, there’s one shortfall associated with the process – The device’s IP address can change from time to time.
Setting a static IP may be required if you regularly share files, share a printer, or when configuring Port forwarding. We will see four methods to do it:
- Via Control Panel
- Via Windows Settings
- Using PowerShell
- Using Command Prompt.
1] Setting a static IP address via Control Panel
Right-click the network (or Wi-Fi) icon visible on Windows 10 Taskbar.
From the list of 2 options displayed, select the latter one – Open Network and Internet settings.
Go to Wi-Fi settings and scroll down a bit to locate ‘Related Settings’ section. When found click on the ‘Change adapter options’ link visible there.
Instantly, a separate window will open and direct you to the Network Connections section of the Control Panel.
Right-click the network connection you need to set a static IP-address for and select ‘Properties‘ option.
After that, select Internet Protocol Version 4 (TCP/IPv4) seen under ‘Networking’ tab and hit the ‘Properties’ button.
Switch the selector to ‘Use the following IP address’.
Now make the entry for the following fields, corresponding to your network setup.
- IP address (Find it using ipconfig /all command)
- Subnet Mask (On a home network, it is 255.255.255.0)
- Default Gateway (It is your router’s IP address.)
In the end, do not forget to check ‘Validate settings upon exit’ option. It helps Windows to quickly check your new IP address and other relevant information to ensure that it works.
If all looks good, press the ‘OK’ button and close out of the network adapter’s properties window.
2] Assign Static IP Address via Settings
Click Settings icon and choose ‘Network & Internet’ tab.
Select Wi-Fi > Current connection, i.e., network to which you are connected.
Scroll down to IP settings section and hit the Edit button.
Then, when the ‘IP settings’ window pops up, hit the drop-down arrow and select ‘Manual‘ option.
Turn on the IPv4 toggle switch.
Now, set the static IP address. Also, set the Subnet prefix length (subnet mask). If your subnet mask is 255.255.255.0, then the subnet prefix length in bits is 24.
Once done, configure the Default Gateway address, Preferred DNS address and Save the changes.
3] Assigning Static IP Address via PowerShell
Open Powershell as Administrator and enter the following command to view your current network configuration-
Following this, note down the following information:
After that, enter the following command to set a static IP address and press Enter.
Now, change DefaultGateway with the default gateway address of your network. Make sure to change the InterfaceIndex number with the one corresponding to your adapter and IPAddress with the IP address you want to assign to your device.
When done, Type the following command to assign a DNS server address and press Enter.
Save the changes and exit.
4] Assign a Static IP Address using Command Prompt
To set a static IP address in Windows 10 using a command prompt, follow the below suggestions:
Right-click on the Start button and select Run to open the Run dialog box.
Type cmd in the text box and press Ctrl+Shift+Enter keyboard shortcut to run the Command Prompt with administrative privileges.
In the Command Prompt window, type in the following text code:
When you press the enter key, it will show all the current network configuration.
Under the network adapter, write down the following information:
- IPv4 Address
- Subnet Mask
- Default Gateway
- DNS Server.
After that, execute the following command to set a new static IP address: