Windows devices, like most other devices, obtain the IP Address dynamically from the DHCP server. Generally, anyway. If you plan to set up a server of any sort or just access the system remotely, setting a static IP is a good idea.
Do note that we’re talking about static private IP addresses here, i.e., ones assigned to devices on your local network. This is different from a static public IP, i.e. WAN IP assigned to your router/modem. You’ll need to get the details from your ISP and configure the router for the latter.
Most routers do support DHCP reservation, which uses a device’s MAC Address to assign a static IP to it from within the DHCP scope. But that, again, falls more on the router configuration side of things and will require a tutorial of its own.
In this article, we’ll instead focus on how you can set a static IPv4 address on Windows devices from the live Windows environment. We’ll do this without accessing the router management interface or anything of the sort.
Table of Contents
IPv4 Address Classes
An IP address is basically an identifier, a unique set of numbers assigned to a device to identify it on a network. In the case of IPv4, which is still primarily used instead of IPv6, an IP address is a 32-bit number. As such, IPv4 addresses are divided into four octets (e.g., 192.168.10.7).
The first octet, i.e., the first decimal number (192 in the above example), determines the IP class. The table below should help you figure out what class any IP address belongs to and what the default subnet mask for it is.
Let’s look at the earlier example once again. We’re dealing with a class C IP address with a subnet mask of 255.255.255.0. This means the first 24 bits, i.e., the first three octets, represent the network part of the IP address (192.168.10). The remaining bits, or the fourth octet, represents the host part (7).
This is important because when setting a static IP, you should only configure the host ID. Changing the network ID would mean the device is no longer on the same network. In the above example, you would only change 7 to something else.
Class C IP Addresses are most commonly used in small LANs, but let’s also look at a class B case (e.g., 172.16.74.23). Here, the first 16 bits (172.16) represent the network ID, and the remaining bits represent the host ID (74.23). Thus, you can change 74.23 to different values in this scenario.
Things to Know Before Setting Static IP
We’ve covered how the IP Address class affects which values you can change. With this in mind, here are some other things you should know when setting a Static IP on your Windows device:
- You can use the
ipconfigcommand in CMD to check the device’s current IP address, subnet mask, and default gateway.
ipconfig /allwill give you much more information, including things like DNS. These will be necessary when setting the static IP.
- The static IP should be set outside the DHCP scope to ensure IP conflicts don’t happen. You can check the DHCP range via the router’s settings page.
- Additionally, you can ping an IP address to ensure it’s not already in use. For instance, if you ping 192.168.18.23 and get “Destination Host is Unreachable” as the output, it usually means the IP isn’t in use.
- In some cases, this output can also occur because the firewall is blocking the connection. Thus, it’s better to use the
arp -acommand. You can use a static IP as long as it’s not on this list.
How to Set Static IP in Windows?
The Network Control Panel applet is very intuitive, and it’s most commonly used to change IP configurations in Windows, so we’ll start with that. Ultimately, the other methods also lead to the same result, so you’re free to use your preferred method.
Through Control Panel
Here are the steps to set a static IP on Windows via the Control Panel:
- If you haven’t already, use the
ipconfigcommand. Note the Default Gateway and Subnet Mask of the interface you want to set a static IP for.
- Now, press Win + R, type
ncpa.cpl, and press Enter.
- Right-click your network connection and select Properties.
- Select Internet Protocol Version 4 (TCP/IPv4) and click on Properties.
- Select the Use the following IP Address option.
- Fill in the Default Gateway and Subnet Mask fields with the values from Step 1.
- In the IP address field, enter the default gateway’s value and change the host ID portion. In the case of Class C addresses, this is the last octet, as we covered earlier.
- If you want to set the DNS server addresses manually, you can do so in the next section.
- Finally, press OK to save the changes.
As stated, you can also set a static IP via Windows settings. Here are the necessary steps for this:
- Press Win + I and select Network & Internet > Status.
- Under the Ethernet or WiFi connection, click on Properties.
- Scroll down to the IP settings section and click on Edit.
- Select Manual IP Assignment and toggle on IPv4.
- Set a static IP address to use in the IP address section.
- Fill in the Subnet prefix length section. Depending on the IP address class, the values are as follows:
Class A – 8
Class B – 16
Class C – 24
- Now, fill in the Default Gateway and DNS sections and save the changes.
Through Command Prompt
As usual, the command prompt allows you to assign a static IP efficiently through the netsh tool. Here are the necessary steps to use it:
- Press Win + R, type
cmd, and press CTRL + Shift + Enter.
ipconfig /alland note the interface name and other details like Default Gateway and Subnet Mask.
- Fill in the appropriate values and execute the following command:
Netsh interface ip set address name=”interfacename” static <device IP> <subnet mask> <default gateway>
- Optionally, you can use the following commands to set the preferred and alternate DNS server addresses:
Netsh interface ip set dns name="interfacename" static <dnsserveraddress>
netsh interface ip add dns name="interfacename" <alternateaddress> index=2
Netsh is a legacy tool. If you want a newer alternative, you can also use Powershell’s NetTCPIP module to set a static IP. Here are the necessary steps for this method:
- Press Win + R, type
powershell, and press CTRL + Shift + Enter.
Get-NetIPConfigurationand note the InterfaceIndex and IPv4 Default Gateway.
- Now, replace the appropriate values and use the following command:
New-NetIPAddress -InterfaceIndex <> -IPAddress <> -PrefixLength <> -DefaultGateway <>
- Use the following command to set the DNS server addresses:
Set-DnsClientServerAddress -InterfaceIndex <> -ServerAddresses <preferreddns>, <alternatedns>