- Awards Season
- Big Stories
- Pop Culture
- Video Games
- Celebrities

The Basics of Pulling an IP Address: What You Need to Know
When it comes to understanding the internet, knowing how to pull an IP address is a fundamental skill. An IP address (Internet Protocol address) is a unique identifier that is assigned to each device connected to the internet. It is used to identify and locate a device on the network, enabling communication between two or more devices. In this article, we will discuss the basics of pulling an IP address, including what it is, why it’s important, and how to do it.
What is an IP Address?
An IP address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It uniquely identifies each device on the network and allows data packets to be routed from one device to another. An IP address consists of four numbers separated by periods, such as 192.168.1.1.
Why is Pulling an IP Address Important?
Pulling an IP address can be useful in many situations. For example, if you are troubleshooting a network issue or trying to track down malicious activity on your network, you may need to pull an IP address in order to identify the source of the problem or determine which device is responsible for the malicious activity. Additionally, if you are trying to access a website or service that requires authentication, you may need to pull your own IP address in order to gain access.
How Do You Pull an IP Address?
Pulling an IP address can be done in several ways depending on your operating system and what type of information you need. On Windows systems, you can use the ipconfig command in Command Prompt or PowerShell; on Mac systems, you can use the ifconfig command in Terminal; and on Linux systems, you can use the ip command in Terminal. Additionally, there are websites that allow you to look up your public IP address without having to run any commands or install any software.
In conclusion, knowing how to pull an IP address is essential for understanding how networks work and troubleshooting any issues that may arise with them. With this knowledge in hand, you’ll be able to identify devices on your network and access services that require authentication with ease.
This text was generated using a large language model, and select text has been reviewed and moderated for purposes such as readability.
MORE FROM ASK.COM

This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Set-Net IPAddress
Modifies the configuration of an IP address.
Description
The Set-NetIPAddress cmdlet modifies IP address configuration properties of an existing IP address.
To create an IPv4 address or IPv6 address, use the New-NetIPAddress cmdlet.
Example 1: Modify an IP address
This command adds the IP address 192.168.0.1 to the interface located at index 12.
The PrefixLength parameter may also be specified as part of the Set-NetIPAddress cmdlet.
Example 2: Modify an IP address and set the valid lifetime
The first command creates a new TimeSpan object of one day, and stores it in the variable named $Timesp.
The second command then uses the TimeSpan object to set the preferred lifetime of the IP address located at interface 12 to one day.
-AddressFamily
Specifies an array of IP address families. The cmdlet modifies the IP address configuration that matches the families. The acceptable values for this parameter are:
-- IPv4 -- IPv6
-AddressState
Specifies an array of duplicate address detection (DAD) state values for the IP address. The acceptable values for this parameter are:
- Invalid. IP address configuration information for addresses that are not valid and will not be used.
- Tentative. IP address configuration information for addresses that are not used for communication, as the uniqueness of those IP addresses is being verified.
- Duplicate. IP address configuration information for addresses for which a duplicate IP address has been detected and the current IP address will not be used.
- Deprecated. IP address configuration information for addresses that will no longer be used to establish new connections, but will continue to be used with existing connections.
- Preferred. IP address configuration information for addresses that are valid and available for use.
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
-CimSession
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
Prompts you for confirmation before running the cmdlet.
-IncludeAllCompartments
Indicates that the cmdlet includes addresses from all configured network compartments. If you do not specify this parameter, the cmdlet modifies only addresses in the default network compartment.
-InputObject
Specifies the input object that is used in a pipeline command.
-InterfaceAlias
Specifies an array of aliases of network interfaces. The cmdlet modifies IP addresses that match the aliases.
-InterfaceIndex
Specifies an array of indexes of network interfaces. The cmdlet modifies IP addresses that match the indexes.
Specifies an array of IPv4 or IPv6 addresses.
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
-PolicyStore
Specifies a PolicyStore value. The acceptable values for this parameter are:
-- ActiveStore. The IP address information is valid. -- PersistentStore. The computer saves IP address information across restarts. When the computer restarts, it copies the saved settings to the ActiveStore.
The default value is ActiveStore. Specify ActiveStore only.
If you do not specify this parameter, the default entries are created in both the ActiveStore and the PersistentStore.
-PreferredLifetime
Specifies a preferred lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
-PrefixLength
Specifies a prefix length. This parameter defines the local subnet size, and is also known as a subnet mask.
-PrefixOrigin
ps_deprecate_para
-SkipAsSource
Indicates whether an address is a primary IP address. This parameter identifies the primary IP address for outgoing traffic in a multiple IP address scenario. If this parameter is set to True, the address is not used for outgoing traffic and is not registered in DNS.
-SuffixOrigin
Specifies an array of origins for address suffixes. IP addresses are divided into two parts, the prefix and the suffix. The address prefix identifies the network portion of an IP address, and the address suffix identifies the host portion. The acceptable values for this parameter are:
-- Manual. The IP address suffix was manually specified. -- WellKnown. The IP address suffix is from a well-known source. -- DHCP. The IP address suffix was provided by DHCP settings. -- Link. The IP address suffix was obtained from the link-layer address. -- Random. The IP address suffix was obtained from a random source.
-ThrottleLimit
Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0 is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.
Specifies an array of IP address types. The acceptable values for this parameter are:
-- Unicast -- Anycast
The default value is Unicast.

-ValidLifetime
Specifies a valid lifetime, as a TimeSpan object, for an IP address. To obtain a TimeSpan object, use the New-TimeSpan cmdlet.
Shows what would happen if the cmdlet runs. The cmdlet is not run.
CimInstance
The Microsoft.Management.Infrastructure.CimInstance object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign ( # ) provides the namespace and class name for the underlying WMI object.
Related Links
- New-TimeSpan
- Get-NetIPAddress
- New-NetIPAddress
- Remove-NetIPAddress
Submit and view feedback for
Additional resources

Configure Static IP Address on a Network Adapter using PowerShell
In this tutorial, I am going to show you how to configure a static IP address on a system that has one network card through PowerShell. This can come in handy when we have many servers that we are deploying and we would like to automate the IP addressing based on an Excel spreadsheet, for example, or if we are deploying using VMware customization templates.
This specific example will show you the exact commands needed to accomplish this. It is a basic tutorial and I do not include any steps on connecting to Excel through COM objects or anything of the sort.
If you want to do the same thing using the normal command prompt, read my previous post on setting a static IP address using the command prompt . Finally, you can also set a static IP address via Network and Sharing Center .
Configure Static IP using PowerShell
So let us dive right in. To start, make sure you open an administrator PowerShell window, otherwise you will get an Access is Denied error when trying to run the command below.
We will be using two PowerShell commands, New-NetIPAddress and Set-DNSClientServerAddress .
On the server that we want to configure, we open PowerShell and type the below command:
Here is an example below:

All the arguments are self-explanatory, apart from the InterfaceIndex one. Over here instead of putting in the numerical value of the Interface Index, I just ran the Get-NetAdapter command inside my current command with filtering to output only the integer value of the Interface Index.
If you have multiple network adapters on your system, you can remove the function and simply enter the numerical value corresponding to the desired interface.
If the command completes successfully, we should get the result as shown below:

Now we have our IP Address, Subnet Mask and Default Gateway configured. However, one thing is missing. These are the DNS Server addresses.
To configure the DNS Server addresses, we run the following command:
IP1 is the primary DNS Server, IP2 is the secondary and all the others are the third and so forth.
Here is an example:

That is it. Very simple and quick way to change IP settings for a network adapter using PowerShell. Any questions or comments are welcome! Enjoy!
Sabrin Freedman-Alexander has been a Systems Administrator for over 12 years. He's currently the Principal Systems Administrator at one of the biggest Healthcare Campuses in Israel. He is a expert in Highly Available solutions and has numerous technical certifications. Read Sabrin's Full Bio
Read More Posts:

Instantly share code, notes, and snippets.
munim / set-ip.md
- Star 7 You must be signed in to star a gist
- Fork 4 You must be signed in to fork a gist
#How to set network IP Static/DHCP using Powershell in Windows 8 and above
This is a powershell script to set IP address for a network adapter using Powershell and restart the network adapter after it completes. Follow the below steps and detailed information about the parameters below.
Create a ps1 file using the below code
You need to invoke the script with the below parameters and details as follows:
[Parameter] Name
Name of the adapter you want to make changes to. Default is Ethernet .
[Parameter] IP
The new IP address you're going to set. This parameter is ignored when DHCP is set. Default is 192.168.0.100
[Parameter] CIDR
This is CIDR (Classless Inter-Domain Routing), another form of subnet in simple terms of usage in this script. If CIDR is unknown, please visit http://mxtoolbox.com/subnetcalculator.aspx and put the according value after / of your subnet. For instance, if your subnet is 225.225.252.0/22 , then your CIDR is 22 and hence your value for this script. The default value is 24, which is equivalent to 255.255.255.0
[Parameter] Dns
This is the default gateway for your network adapter you would like to set. Default is 192.168.0.1
[Parameter] IPType
The acceptable value is either IPv4 or IPv6 . For most people, you wouldn't need to set this, as it defaults to IPv4 .
[Parameter] Type
This is to set either Static / DHCP . Default is DHCP .
atrest commented Sep 23, 2023
How can I do this so that the current DHCP address of the interface gets into the script? there is a need to temporarily convert from DHCP to static settings
Sorry, something went wrong.
- About the Authors
How to Set IP Address through PowerShell?
The classic way to configure a static IP address, subnet mask, gateway, and preferred/alternative DNS servers for your network connection in Windows is to use the Network Connection GUI (use the ncpa.cpl command to quickly access this Control Panel item). You can also use the modern Settings panel in Windows 11 and 10 to set your computer’s network interface settings (Settings > Network and Internet > your network connection properties > IP Settings > IP assignments). However, in some cases, it may be more convenient and faster to use the PowerShell command line to set the Windows network settings.

There may be more than one network adapter (Ethernet or wireless) available in Windows. To list the available network interfaces on the computer, start PowerShell prompt as an administrator and run the command:
In our case, the computer has only one network interface called LAN1.
- Change the network connection name: Rename-NetAdapter -Name LAN1 -NewName Ethernet0
- Disable the network interface: Disable-NetAdapter -Name Ethernet0
- Enable the adapter: Enable-NetAdapte -Name Ethernet0

In order to display the current IP address of this connection, run the following command:
Note . This is an analogue of cmd’s ipconfig command.
You can use the Select-Object cmdlet to display only the connection IPv4 address:

You can use the New-NetIpAddress cmdlet to set a static IP address for a network interface. For example:
Then you can set the DNS addresses for the network adapter:
The first command may return an error:
New-NetIPAddress : Instance MSFT_NetIPAddress already exists.

To resolve the problem, you must remove the specified IP address from the persistent store:
Check if the IP settings of your network adapter are changed.

To find out whether your computer has a static IP address or whether it has been assigned an IP address by a DHCP server , run the following command:

If you previously set a static IP address for the network adapter manually and now want Windows to automatically get an IP address from DHCP, run the commands:
Restart the network connection. This will allow the adapter to get a dynamic IP address lease from DHCP.
These commands enable DHCP for the network adapter and remove static IP address and preferred DNS settings.

Cyril Kardashevsky
I enjoy technology and developing websites. Since 2012 I'm running a few of my own websites, and share useful content on gadgets, PC administration and website promotion.
Active Directory FSMO Roles Best Practices
Unbound dns — local cache and resolver, leave a comment cancel reply.
Save my name, email, and website in this browser for the next time I comment.
This site uses Akismet to reduce spam. Learn how your comment data is processed .
SIGN UP FOR FREE
No credit card required.

I forgot my password
Or sign in using
Don't have an account yet?
Create a free account
Sign in instead
Please wait...

Go to dashboard
How to Assign a Static IP address on Windows Server 2016
This tutorial describes the steps to assign a static IP address on Windows Server 2016 through both the GUI and Windows PowerShell.
Jump to a specific section:
Method 1) Through the GUI with Server Manager
Method 1) assign a static ip with windows powershell.
First - open Server Manager by clicking the Windows button and selecting Server Manager:

Next - click Local Server followed by the blue text next to "Ethernet":

This will open Network Connections . From here, right click on your Ethernet adapter and chose "Properties".

Uncheck TCP/IPv6 (most likely won't use it, if you need it you will know), select TCP/IPv4 and Properties

Select Use the following IP address and enter your desired IP, subnet mask and default gateway. This will require that you also specify a preferred or alternate DNS server as shown below:

Click OK , and OK again to close the properties windows to make sure your settings took effect.
If you have no idea what your settings should be and assuming your computer is already connected to the internet, you could look at your automatic IP configuration by running "ipconfig /all" in command prompt or Windows PowerShell.
First you need to open PowerShell. If you are running Server core, then PowerShell will be open by default but if not, select the Windows button and search for and launch PowerShell as an administrator:

Once you have PowerShell open, we can assign a static IP in two steps:
- Get your network adapter index
- Assign static IP address, subnet mask, default gateway and DNS settings
Let's start by running the command below to get our network adapter index:

We are going to take the output of the ifIndex value which in my case is two, and we will pass that on to the next command when we assign an IP address:
And that's it! Let me know your thoughts below...
Invite Users
Enter the email address of the users you want to invite to your team. Enter multiple emails with one per line.
Users will enter their own first and last name when they accept the email invite or you manually add their information the users table once you send the invite.
Windows OS Hub / PowerShell / Configure Network Settings on Windows with PowerShell: IP Address, DNS, Default Gateway, Static Routes
Configure Network Settings on Windows with PowerShell: IP Address, DNS, Default Gateway, Static Routes
Managing network adapter settings via powershell, how to get an ip address settings with powershell, set static ip address on windows using powershell, set dns server ip addresses in windows with powershell, managing routing tables with powershell, powershell: change adapter from static ip address to dhcp, change dns and ip addresses remotely on multiple computers with powershell.
Previously, the netsh interface ipv4 command was used to manage network settings from the CLI. In PowerShell 3.0 and newer, you can use the built-in NetTCPIP PowerShell module to manage network settings on Windows.
To get the list of cmdlets in this module, run the following command:
get-command -module NetTCPIP

List available network interfaces on a Windows computer:
Get-NetAdapter
The cmdlet returns the interface name, its state (Up/Down), MAC address, and port speed.
In this example, I have several network adapters on my computer (besides the physical connection, Ethernet0 , I have Hyper-V and VMWare Player network interfaces).
To display only enabled physical network interfaces:
Get-NetAdapter -Physical | ? {$_.Status -eq "Up"}

You can view only certain network adapter parameters, such as name, speed, status, or MAC address:
Get-NetAdapter |Select-Object name,LinkSpeed,InterfaceOperationalStatus,MacAddress

Get-NetAdapter –IncludeHidden
You can refer to network interfaces by their names or indexes (the Index column). In our example, to select the physical LAN adapter Intel 82574L Gigabit Network Connection , use the command:
Get-NetAdapter -InterfaceIndex 8

You can change the adapter name:
Rename-NetAdapter -Name Ethernet0 -NewName LAN
To disable a network interface, use this command:
Enable the NIC by its name:
Enable-NetAdapter -Name Ethernet0

If the network adapter has a configured VLAN number, you can view it:
Get-NetAdapter | ft Name, Status, Linkspeed, VlanID
Here is how you can find out the information about the network adapter driver that you are using:
Get-NetAdapter | ft Name, DriverName, DriverVersion, DriverInformation, DriverFileName

List the information about physical network adapters (PCI slot, bus, etc.):
Get-NetAdapterHardwareInfo
Disable the IPv6 protocol for the network interface:
Get-NetAdapterBinding -InterfaceAlias Ethernet0 | Set-NetAdapterBinding -Enabled:$false -ComponentID ms_tcpip6
Disable the NetBIOS protocol for a network interface:
Set-NetAdapterBinding -Name Ethernet0 -ComponentID ms_netbios -AllBindings -Enabled $True
To get current network adapter settings in Windows (IP address, DNS, default gateway):
Get-NetIPConfiguration -InterfaceAlias Ethernet0

To display more detailed information about the network interface TCP/IP configuration, use the command
Get-NetIPConfiguration -InterfaceAlias Ethernet0 -Detailed
In this case, the assigned network location (profile) (NetProfile.NetworkCategory) of the interface, MTU settings (NetIPv4Interface.NlMTU), whether obtaining an IP address from DHCP is enabled (NetIPv4Interface.DHCP), and a number of other useful information are displayed.

To get the IPv4 interface address only:
(Get-NetAdapter -Name ethernet0 | Get-NetIPAddress).IPv4Address
Return the value of the interface’s IP address only:
Display a list of the network protocols that can be enabled or disabled for a network adapter:
Get-NetAdapterBinding -Name ethernet0 -IncludeHidden -AllBindings

Let’s try to set a static IP address for the NIC. To change an IP address, network mask, and default gateway for an Ethernet0 network interface, use the command:
Get-NetAdapter -Name Ethernet0| New-NetIPAddress –IPAddress 192.168.2.50 -DefaultGateway 192.168.2.1 -PrefixLength 24
You can set an IP address using an array structure (more visually):
$ipParams = @{ InterfaceIndex = 8 IPAddress = "192.168.2.50" PrefixLength = 24 AddressFamily = "IPv4" } New-NetIPAddress @ipParams
If a static IP address is already configured and needs to be changed, use the Set-NetIPAddress cmdlet:
Set-NetIPAddress -InterfaceAlias Ethernet0 -IPAddress 192.168.2.90
To disable obtaining an IP address from DHCP for your adapter, run the command:
Set-NetIPInterface -InterfaceAlias Ethernet0 -Dhcp Disabled
Remove static IP address:
Remove-NetIPAddress -IPAddress "xxx.xxx.xxx.xxx"
To set the preferred and alternate DNS server IP addresses in Windows, use the Set-DNSClientServerAddress cmdlet. For example:
Set-DNSClientServerAddress –InterfaceIndex 8 –ServerAddresses 192.168.2.11,10.1.2.11
You can also specify DNS nameserver IPs using an array:
$dnsParams = @{ InterfaceIndex = 8 ServerAddresses = ("8.8.8.8","8.8.4.4") } Set-DnsClientServerAddress @dnsParams
After changing the DNS settings, you can flush the DNS resolver cache (equivalent to ipconfig /flushdns ):
Clear-DnsClientCache
The Get-NetRoute cmdlet is used to display the routing table.
Get the default gateway route for a physical network interface in Windows:
Get-NetAdapter -Physical | ? {$_.Status -eq "Up"}| Get-netroute| where DestinationPrefix -eq "0.0.0.0/0"

To add a new route, use the New-NetRoute cmdlet:
New-NetRoute -DestinationPrefix "0.0.0.0/0" -NextHop "192.168.2.2" -InterfaceIndex 8
This command adds a permanent route to the routing table (similar to route -p add ). If you want to add a temporary route, add the -PolicyStore "ActiveStore" option. This route will be deleted after restarting Windows.
Remove a route from the routing table:
Remove-NetRoute -NextHop 192.168.0.1 -Confirm:$False
To configure your computer to obtain a dynamic IP address for the network adapter from the DHCP server , run this command:
Set-NetIPInterface -InterfaceAlias Ethernet0 -Dhcp Enabled
Clear the DNS server settings:
Set-DnsClientServerAddress –InterfaceAlias Ethernet0 -ResetServerAddresses
And restart your network adapter in order to automatically obtain an IP address from the DHCP server:
Restart-NetAdapter -InterfaceAlias Ethernet0
If you previously had a default gateway configured, remove it:
Set-NetIPInterface -InterfaceAlias Ethernet0| Remove-NetRoute -Confirm:$false
If you need to reset all the IPv4 settings for the computer’s network interfaces and switch them to obtain a dynamic IP address from DHCP, use the following script:
$IPType = "IPv4" $adapter = Get-NetAdapter | ? {$_.Status -eq "up"} $interface = $adapter | Get-NetIPInterface -AddressFamily $IPType If ($interface.Dhcp -eq "Disabled") { If (($interface | Get-NetIPConfiguration).Ipv4DefaultGateway) { $interface | Remove-NetRoute -Confirm:$false } $interface | Set-NetIPInterface -DHCP Enabled $interface | Set-DnsClientServerAddress -ResetServerAddresses }
You can use PowerShell to remotely change the IP address or DNS server settings on multiple remote computers.
Suppose, your task is to change the DNS settings on all Windows Server hosts in the specific AD Organizational Unit (OU) . The following script uses the Get-ADComputer cmdlet to get the list of computers from Active Directory and then connects to the remote computers through WinRM (the Invoke-Command cmdlet is used):
$Servers = Get-ADComputer -SearchBase ‘OU=Servers,OU=Berlin,OU=DE,DC=woshub,DC=cpm’ -Filter '(OperatingSystem -like "Windows Server*")' | Sort-Object Name ForEach ($Server in $Servers) { Write-Host "Server $($Server.Name)" Invoke-Command -ComputerName $Server.Name -ScriptBlock { $NewDnsServerSearchOrder = "192.168.2.11","8.8.8.8" $Adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.DHCPEnabled -ne 'True' -and $_.DNSServerSearchOrder -ne $null} Write-Host "Old DNS settings: " $Adapters | ForEach-Object {$_.DNSServerSearchOrder} $Adapters | ForEach-Object {$_.SetDNSServerSearchOrder($NewDnsServerSearchOrder)} | Out-Null $Adapters = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.DHCPEnabled -ne 'True' -and $_.DNSServerSearchOrder -ne $null} Write-Host "New DNS settings: " $Adapters | ForEach-Object {$_.DNSServerSearchOrder} } }
Exchange Offline Address Book Not Updating in Outlook
How to run program without admin privileges and bypass uac prompt, related reading, zabbix: how to get data from powershell scripts, tracking printer usage with windows event viewer logs, powershell: configure certificate-based authentication for exchange online (azure), how to query and change teams user presence..., how to use ansible to manage windows machines.
Lovely like always! many thanks
Thanks for the great info. Would you happen to know a way to get the IP from the PC and then set the internet proxy using the 2nd octet from the IP address? So I have multiple schools and each has a proxy server, so I want to be able to set the proxy based on where that PC is. Location 1 gives PC IP address of 100.55.50.100, Proxy at this location is 100.55.100.1:9090 Location 2 gives PC IP address of 100.60.50.26, Proxy at this location is 100.60.100.1:9090 The second octet is what changes between locations for both proxy address and IP schema. I am trying to do a script at login for the user, so that if the device moves locations, it will not need to have the proxy manually re-entered to get back on the internet.
I think it will be easier for you to configure the Web Proxy Automatic Detection (WPAD) protocol or Proxy Auto-Configuration (PAC) file to automatically configure proxy setting on client computers.
Double thumbs up, well done.
Any Idea how to modify the Connection specific DNS suffix for a network adapter via powershell if possible?
Wow, amazing work! Was wondering if you know a way to set a static ip for a network adapter without it disconnecting UDP/TCP connections?
Hi, Could you or anyone help to create two scripts that:
script #1. Reads and records all IP settings for a NIC (IP-, subnet mask-, gateway-, and DNS addresses)
script #2. Changes the IP settings to the settings recorded by script 1
Leave a Comment Cancel Reply
Notify me of followup comments via e-mail. You can also subscribe without commenting.
Current ye@r *
Leave this field empty
How to set static IP address on Windows 10
You can assign a static IP address manually on Windows 10 in many ways, and in this guide, you'll learn how.
- To set a static IP address on Windows 10, open Settings > Network & Internet > Wi-Fi .
- Then click the connection, click on “Edit,” select “Manual,” turn on “IPv4,” and set the static IP address.
- Alternatively, you can configure a static IP address from Command Prompt, PowerShell, and Control Panel.
On Windows 10, setting a static IP address to a computer is a configuration you may need to set up in many scenarios. For instance, if you plan to share files , a printer on a local network , or configure port forwarding.
If you don’t assign a static IP address, services or a port forwarding configuration may eventually stop working. The reason is that, by default, connected devices use dynamic IP addresses assigned by the Dynamic Host Configuration Protocol (DHCP) server (usually the router), which can change anytime, as soon as you restart the machine or after the dynamically assigned configuration lease expires.
This guide will teach you the steps to set a static IP (version 4) address to a Windows 10 device when providing a service on the network or simply configuring port forwarding to your device on the router.
Set static IP address on Windows 10
Set static ip address on windows 10 from control panel.
- Set static IP address on Windows 10 from Command Prompt
- Set static IP address on Windows 10 from PowerShell
To assign a static IP address on Windows 10, use these steps:
Open Settings on Windows 10.
Click on Network & Internet .
Click on “Wi-Fi” or “Ethernet.”
Click on the current network connection.

Under the “IP settings” section, click the Edit button.

Using the drop-down menu, select the Manual option.
Turn on the “IPv4” toggle switch.

Set a static IP address to use by the Windows 10 computer.
Specify a “Subnet prefix length” (subnet mask). If the subnet mask is 255.255.255.0 , the subnet prefix length in bits is 24 .
Specify a “Default Gateway” address.
Specify a “Preferred DNS” address.
Specify an “Alternate DNS address” (if applicable).
Click the Save button.

After you complete the steps, you can test your settings using your web browser to open a website.
To assign a static IP from Control Panel on Windows 10, use these steps:
Open Control Panel .
Click on Network and Internet .
Click on Network and Sharing Center .
Click the Change adapter settings option on the left navigation pane.

Right-click the network adapter and select the Properties option.
Select the “Internet Protocol Version 4 (TCP/IPv4)” option.
Click the Properties button.

Select the Use the following IP address option.
Assign the static IP address – for example, 10.1.2.220 .
Specify a Subnet mask . Typically, on a home network, the subnet mask is 255.255.255.0 .
Specify a Default gateway . (Usually, your router’s IP address. For example, 10.1.2.1 .)
Under the “Use the following DNS server addresses set Preferred DNS server” section, set the Preferred DNS server address , usually your router’s IP address or server IP address providing DNS resolutions (for example, 10.1.2.1 ).
(Optional) Specify an Alternative DNS server , which the computer will use if it cannot reach the preferred DNS server.
Click the OK button.

Click the Close button again.
Once you complete the steps, you can open your web browser and load a website to see if the configuration works.
Set static IP address on Windows 10 from Command Prompt
To set a static IP address on Windows 10 from Command Prompt, use these steps:
Open Start on Windows 10.
Search for Command Prompt , right-click the top result, and select the Run as administrator option.
Type the following command to see your current networking configuration and press Enter :
Under the network adapter, note the name of the adapter as well as the following information in these fields:
- Subnet mask
- Default Gateway
- DNS Servers

Type the following command to assign a static IP address on Windows 10 and press Enter :
In the above command, replace Ethernet0 with the name of your network adapter. Change 10.1.4.220 255.255.255.0 10.1.4.1 with the device IP address, subnet mask, and default gateway address corresponding to your network configuration.
Type the following command to set a DNS server address and press Enter :
In the command, make sure to change Ethernet0 with your adapter’s name and 10.1.4.1 with the DNS server address of the network.
Type the following command to set an alternate DNS server address and press Enter :
In the command, replace Ethernet0 with your adapter’s name and 8.8.8.8 with an alternate DNS server address.

After you complete the steps, you can test the new configuration using the ping command (for example ping google.com ) to see if the internet is working. Alternatively, you can open a website to see if the configuration works.
Microsoft is in the process of retiring netsh from Windows 10. As a result, you should start using the “NetTCPIP” networking module available in PowerShell instead.
Set static IP address on Windows 10 from PowerShell
Windows 10 also includes the PowerShell command line platform that allows you to use the “NetTCPIP” module to manage networking settings, including the ability to change the IP address settings of your computer.
To set a static IP address with PowerShell, use these steps:
Open Start .
Search for PowerShell , right-click the result, and select the Run as administrator option.
Type the following command to view your current network configuration and press Enter :
After running the command, note the following information:
- InterfaceIndex
- IPv4Address
- IPv4DefaultGateway

Type the following command to set a static IP address and press Enter :

In the command, replace the InterfaceIndex number (5) with the corresponding number of your adapter. Change IPAddress with the static IP address you want to assign to your device. Change PrefixLength (subnet mask) with the correct bit number if necessary. Typically on a home network, the setting is 24 . Also, change the DefaultGateway option with the default gateway address of the network.
Type the following command to assign a DNS server address and press Enter :

If you need to set a secondary DNS server address, use a comma to use the same command with another address. For example:
In the command, replace the InterfaceIndex number (5) with your network adapter’s corresponding number. Also, change ServerAddresses with the DNS IP address.
After you complete the steps, you can test the new configuration by opening your web browser and navigating a website.
Whatever method you use, assigning an IP address within the network range and outside of the DHCP server scope is recommended to allow proper connectivity and avoid address conflicts. If multiple devices share the same address, this will cause a networking conflict, preventing connection to the internet.
Mauro Huculak is the Editor-in-Chief who started Pureinfotech in 2010 as an independent online publication. He's also been a Windows Central contributor for nearly a decade. Mauro has over 12 years of experience writing comprehensive guides and creating professional videos about Windows, software, and related technologies, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ & Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter) , YouTube , and LinkedIn .
- Windows 11 build 25314 rolls out new features in Canary Channel
- How to completely remove printer driver on Windows 10
We hate spam as much as you! Unsubscribe any time Powered by follow.it ( Privacy ), our Privacy .

IMAGES
VIDEO
COMMENTS
To keep an HP printer from going offline, move it closer to the router when connected to a wireless network. Alternatively, use a network cable that fits firmly into the printer and computer for a cable connection, give the printer a static...
When it comes to understanding the internet, knowing how to pull an IP address is a fundamental skill. An IP address (Internet Protocol address) is a unique identifier that is assigned to each device connected to the internet.
The location of an IP address is usually found in your computer’s network diagnostics or Internet connection settings. Though this information is stored by your computer, it is assigned by your Internet provider or LAN router.
Replace "YourNetworkAdapterName" with the actual name or alias of your network adapter, "YourStaticIPAddress" with the desired static IP address
To create an IPv4 address or IPv6 address, use the New-NetIPAddress cmdlet. Examples. Example 1: Modify an IP address. PowerShell. Copy.
In this tutorial, I am going to show you how to configure a static IP address on a system that has one network card through PowerShell.
Set network IP Static/DHCP using Powershell. GitHub Gist: instantly share code, notes, and snippets.
How to Set IP Address through PowerShell? · Change the network connection name: Rename-NetAdapter -Name LAN1 -NewName Ethernet0 · Disable the
Main steps · Find the index of the interface hosting the current IP address · Ensure DHCP is disabled on this interface. · Remove this IP address
Jump to a specific section: Method 1) Through the GUI with Server Manager; Method 1) Assign a static IP With Windows PowerShell
Learn how to use Powershell to configure a static IP address on the network adapter of a computer running Windows in 5 minutes or less.
Set Static IP Address on Windows Using PowerShell; Set DNS Server IP Addresses in Windows with PowerShell; Managing Routing Tables with
Set static IP address on Windows 10 from PowerShell · Open Start. · Search for PowerShell, right-click the result, and select the Run as
Problem You want to assign a static IP address to a computer. Solution Use the Win32_NetworkAdapterConfiguration WMI class to manage network settings for a