Skip to content

Windows Server Network Configuration

This article explains how to manage Windows Server network configuration consistently using PowerShell.
It covers static IP setup, DNS configuration, routing priority adjustment, and key considerations when managing multiple NICs.


VariableExampleDescription
<<INTERFACE_ALIAS>>Ethernet0Target network adapter name
<<IP_ADDRESS>>192.168.10.100Static IP address
<<PREFIX_LENGTH>>24Subnet prefix length (e.g., 255.255.255.0 → 24)
<<GATEWAY>>192.168.10.1Default gateway
<<DNS1>>192.168.10.10Primary DNS server
<<DNS2>>8.8.8.8Secondary DNS server (optional)

Step 1: Check Current Network Configuration

Section titled “Step 1: Check Current Network Configuration”

List existing NICs and review their IP configurations.

Terminal window
# List adapters
Get-NetAdapter | Select-Object Name, Status, MacAddress, LinkSpeed
# Show IP configuration
Get-NetIPAddress | Select-Object InterfaceAlias, IPAddress, PrefixLength, DefaultGateway, PrefixOrigin
OriginTypeMeaningNotes
ManualManually assigned static addressExplicitly configured via PowerShell or GUI
DHCPAutomatically assigned by DHCP serverEnabled with Set-NetIPInterface -Dhcp Enabled
WellKnownSystem-reserved link-local or APIPA addressUsed when DHCP is unavailable (e.g., 169.254.x.x)

Disable DHCP and assign a fixed IP address.

Terminal window
# Disable DHCP
Set-NetIPInterface -InterfaceAlias "<<INTERFACE_ALIAS>>" -Dhcp Disabled
# Remove existing DHCP address (if any)
Get-NetIPAddress -InterfaceAlias "<<INTERFACE_ALIAS>>" -AddressFamily IPv4 |
Where-Object { $_.PrefixOrigin -eq "Dhcp" } |
Remove-NetIPAddress -Confirm:$false
# Set static IP
New-NetIPAddress `
-InterfaceAlias "<<INTERFACE_ALIAS>>" `
-IPAddress "<<IP_ADDRESS>>" `
-PrefixLength <<PREFIX_LENGTH>> `
-DefaultGateway "<<GATEWAY>>"

Note:
Use Remove-NetIPAddress only to remove DHCP-assigned addresses.
Avoid running this command on a remotely connected NIC to prevent connection loss.


Specify DNS servers and confirm the settings.

Terminal window
# Configure DNS
Set-DnsClientServerAddress `
-InterfaceAlias "<<INTERFACE_ALIAS>>" `
-ServerAddresses ("<<DNS1>>","<<DNS2>>")
# Verify DNS settings
Get-DnsClientServerAddress -InterfaceAlias "<<INTERFACE_ALIAS>>"

Clear the DNS cache and test name resolution:

Terminal window
Clear-DnsClientCache
Resolve-DnsName "www.microsoft.com"

Step 4: Set Priority in Multi-NIC Environments

Section titled “Step 4: Set Priority in Multi-NIC Environments”

When multiple networks exist, manually adjust routing priority (InterfaceMetric).
Smaller values indicate higher priority.

Terminal window
# Check current metrics
Get-NetIPInterface | Sort-Object -Property InterfaceMetric |
Select-Object InterfaceAlias, AddressFamily, InterfaceMetric
# Set preferred NIC priority (management NIC first)
Set-NetIPInterface -InterfaceAlias "<<INTERFACE_ALIAS>>" -InterfaceMetric 10

Recommended Values:

  • Management LAN: 10
  • Backup LAN: 20–50
  • Cluster / iSCSI traffic: 100 or higher

Check network reachability and DNS resolution.

Terminal window
# Test gateway connectivity
Test-Connection "<<GATEWAY>>" -Count 4
# Test DNS name resolution
Resolve-DnsName "www.microsoft.com"

Tip:
If DNS settings are not applied properly, restart the DNS client service:

Terminal window
net stop dnscache && net start dnscache

By default, Windows Server enables both IPv4 and IPv6.
If IPv6 is unused in your environment, disable it to prevent unnecessary route advertisements and inconsistent name resolution.

Terminal window
# Check IPv6 binding status
Get-NetAdapterBinding `
-InterfaceAlias "<<INTERFACE_ALIAS>>" `
-ComponentID "ms_tcpip6"
# Disable IPv6
Disable-NetAdapterBinding `
-InterfaceAlias "<<INTERFACE_ALIAS>>" `
-ComponentID "ms_tcpip6" `
-PassThru
# Verify again
Get-NetAdapterBinding `
-InterfaceAlias "<<INTERFACE_ALIAS>>" `
-ComponentID "ms_tcpip6"

Re-enable IPv6 if required:

Terminal window
Enable-NetAdapterBinding `
-InterfaceAlias "<<INTERFACE_ALIAS>>" `
-ComponentID "ms_tcpip6"

  • Fix NIC Names
    Prevent automatic renaming by assigning a management label:
    Terminal window
    Rename-NetAdapter -Name "<<INTERFACE_ALIAS>>" -NewName "LAN-Primary"
  • Remove Unnecessary Routes
    Avoid duplicate or invalid routes by explicitly cleaning them:
    Terminal window
    Get-NetRoute -AddressFamily IPv4
    Remove-NetRoute -DestinationPrefix "0.0.0.0/0" -InterfaceAlias "BackupNIC" -Confirm:$false

Terminal window
# Disable adapter
Disable-NetAdapter -Name "<<INTERFACE_ALIAS>>" -Confirm:$false
# Enable adapter
Enable-NetAdapter -Name "<<INTERFACE_ALIAS>>"

Terminal window
Remove-NetIPAddress -InterfaceAlias "<<INTERFACE_ALIAS>>" -IPAddress "<<IP_ADDRESS>>" -Confirm:$false
Set-NetIPInterface -InterfaceAlias "<<INTERFACE_ALIAS>>" -Dhcp Enabled

PowerShell provides a precise and repeatable way to manage Windows Server network configurations.
In multi-NIC environments, routing priority control and explicit DNS configuration are critical for stable operations.
Implement script-based configuration from the start to streamline rebuilds and deployments across environments.