How to Assign a Static IP Address in Windows 11 Using PowerShell

While the Windows 11 Settings app and legacy Network Connections Control Panel offer graphical interfaces for assigning static IP addresses, configuring network adapters via the graphical user interface (GUI) can be tedious, error-prone, and impossible on headless or remote management setups.

For system administrators, developers, and power users, Windows 11 includes the robust NetTCPIP PowerShell module. Using high-level cmdlets like New-NetIPAddress and Set-DnsClientServerAddress, you can script, audit, and assign static IPv4 or IPv6 configurations in seconds. Here is how to assign a static IP address, subnet mask, default gateway, and DNS servers in Windows 11 using PowerShell.

Step 1: Launch an Elevated PowerShell Session

Modifying network interface parameters requires local administrator rights:

  1. Right-click the Start button on your Windows 11 taskbar (or press Windows Key + X).
  2. Select Terminal (Admin) or PowerShell (Admin) from the menu.
  3. Click Yes when prompted by the User Account Control (UAC) dialogue.

Step 2: Identify Your Network Adapter Interface

Before assigning an IP address, identify the exact name (InterfaceAlias) or index number (ifIndex) of the target network adapter:

Get-NetAdapter | Select-Object Name, InterfaceDescription, Status, LinkSpeed, ifIndex

Locate your active adapter—typically named "Ethernet" for wired connections or "Wi-Fi" for wireless interfaces—and take note of its exact name.

Step 3: Check the Current IP Configuration

To inspect your adapter’s existing DHCP or static IP configuration, execute:

Get-NetIPAddress -InterfaceAlias "Ethernet" -AddressFamily IPv4

This displays your current IPv4 address, prefix length (subnet mask), and interface index.

Step 4: Assign a Static IP Address and Default Gateway

To assign a static IP, use the New-NetIPAddress cmdlet. Specify the network interface alias, your chosen IP address, the subnet prefix length, and the default gateway IP:

New-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.1.150" -PrefixLength 24 -DefaultGateway "192.168.1.1"

In this command:

  • -InterfaceAlias "Ethernet": Targets your specific network interface.
  • -IPAddress "192.168.1.150": The static IPv4 address you are assigning to your machine.
  • -PrefixLength 24: Specifies the subnet mask in CIDR notation (24 corresponds to 255.255.255.0; 16 corresponds to 255.255.0.0).
  • -DefaultGateway "192.168.1.1": The local router or gateway address responsible for forwarding traffic outside your local subnet.

Note: If the adapter already has an existing static IP assigned on that subnet, remove it first using Remove-NetIPAddress -InterfaceAlias "Ethernet" -IPAddress "192.168.1.50" -Confirm:$false to prevent multi-homing conflicts.

Step 5: Configure Static DNS Server Addresses

Assigning a static IP does not automatically configure Domain Name System (DNS) resolvers. If your DNS is still set to obtain automatically from DHCP, web browsing and domain resolution may fail. Assign primary and secondary DNS resolvers using Set-DnsClientServerAddress:

Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("1.1.1.1", "1.0.0.1")

This example assigns Cloudflare’s high-speed public resolvers. If you prefer Google Public DNS, replace the array values with ("8.8.8.8", "8.8.4.4"), or input your local corporate domain controller IP addresses.

Step 6: Verify the New Configuration and Connectivity

To audit your complete network configuration in a single formatted view, use Get-NetIPConfiguration:

Get-NetIPConfiguration -InterfaceAlias "Ethernet"

The console will display the interface name, assigned IPv4 address, default gateway, and active DNS servers.

Next, verify external internet and DNS connectivity using Test-NetConnection:

Test-NetConnection -ComputerName "digitash.com" -Port 443

If the final line returns TcpTestSucceeded : True, your static network configuration is fully operational.

How to Revert Back to Dynamic DHCP (Automatic IP and DNS)

If you ever need to return your workstation to automatically obtain an IP address and DNS servers from your network router via DHCP, run these two commands:

# Enable DHCP for IP address assignment
Set-NetIPInterface -InterfaceAlias "Ethernet" -Dhcp Enabled

# Reset DNS server assignment back to DHCP
Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ResetServerAddresses

Windows 11 will immediately release the static binding, send a DHCP request to your local router, and receive a new dynamic lease automatically.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.