Windows Server Network Configuration
Overview
Section titled “Overview”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.
Variable Definitions
Section titled “Variable Definitions”| Variable | Example | Description |
|---|---|---|
<<INTERFACE_ALIAS>> | Ethernet0 | Target network adapter name |
<<IP_ADDRESS>> | 192.168.10.100 | Static IP address |
<<PREFIX_LENGTH>> | 24 | Subnet prefix length (e.g., 255.255.255.0 → 24) |
<<GATEWAY>> | 192.168.10.1 | Default gateway |
<<DNS1>> | 192.168.10.10 | Primary DNS server |
<<DNS2>> | 8.8.8.8 | Secondary 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.
# List adaptersGet-NetAdapter | Select-Object Name, Status, MacAddress, LinkSpeed
# Show IP configurationGet-NetIPAddress | Select-Object InterfaceAlias, IPAddress, PrefixLength, DefaultGateway, PrefixOrigin| OriginType | Meaning | Notes |
|---|---|---|
| Manual | Manually assigned static address | Explicitly configured via PowerShell or GUI |
| DHCP | Automatically assigned by DHCP server | Enabled with Set-NetIPInterface -Dhcp Enabled |
| WellKnown | System-reserved link-local or APIPA address | Used when DHCP is unavailable (e.g., 169.254.x.x) |
Step 2: Switch from DHCP to Static IP
Section titled “Step 2: Switch from DHCP to Static IP”Disable DHCP and assign a fixed IP address.
# Disable DHCPSet-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 IPNew-NetIPAddress ` -InterfaceAlias "<<INTERFACE_ALIAS>>" ` -IPAddress "<<IP_ADDRESS>>" ` -PrefixLength <<PREFIX_LENGTH>> ` -DefaultGateway "<<GATEWAY>>"Note:
UseRemove-NetIPAddressonly to remove DHCP-assigned addresses.
Avoid running this command on a remotely connected NIC to prevent connection loss.
Step 3: Configure DNS Servers
Section titled “Step 3: Configure DNS Servers”Specify DNS servers and confirm the settings.
# Configure DNSSet-DnsClientServerAddress ` -InterfaceAlias "<<INTERFACE_ALIAS>>" ` -ServerAddresses ("<<DNS1>>","<<DNS2>>")
# Verify DNS settingsGet-DnsClientServerAddress -InterfaceAlias "<<INTERFACE_ALIAS>>"Clear the DNS cache and test name resolution:
Clear-DnsClientCacheResolve-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.
# Check current metricsGet-NetIPInterface | Sort-Object -Property InterfaceMetric | Select-Object InterfaceAlias, AddressFamily, InterfaceMetric
# Set preferred NIC priority (management NIC first)Set-NetIPInterface -InterfaceAlias "<<INTERFACE_ALIAS>>" -InterfaceMetric 10Recommended Values:
- Management LAN:
10- Backup LAN:
20–50- Cluster / iSCSI traffic:
100or higher
Step 5: Verify Connectivity
Section titled “Step 5: Verify Connectivity”Check network reachability and DNS resolution.
# Test gateway connectivityTest-Connection "<<GATEWAY>>" -Count 4
# Test DNS name resolutionResolve-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
Step 6: Disable IPv6 (Optional)
Section titled “Step 6: Disable IPv6 (Optional)”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.
# Check IPv6 binding statusGet-NetAdapterBinding ` -InterfaceAlias "<<INTERFACE_ALIAS>>" ` -ComponentID "ms_tcpip6"
# Disable IPv6Disable-NetAdapterBinding ` -InterfaceAlias "<<INTERFACE_ALIAS>>" ` -ComponentID "ms_tcpip6" ` -PassThru
# Verify againGet-NetAdapterBinding ` -InterfaceAlias "<<INTERFACE_ALIAS>>" ` -ComponentID "ms_tcpip6"Re-enable IPv6 if required:
Enable-NetAdapterBinding ` -InterfaceAlias "<<INTERFACE_ALIAS>>" ` -ComponentID "ms_tcpip6"Step 7: Best Practices
Section titled “Step 7: Best Practices”- 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 IPv4Remove-NetRoute -DestinationPrefix "0.0.0.0/0" -InterfaceAlias "BackupNIC" -Confirm:$false
Enable or Disable a Network Adapter
Section titled “Enable or Disable a Network Adapter”# Disable adapterDisable-NetAdapter -Name "<<INTERFACE_ALIAS>>" -Confirm:$false# Enable adapterEnable-NetAdapter -Name "<<INTERFACE_ALIAS>>"Remove Static IP and Revert to DHCP
Section titled “Remove Static IP and Revert to DHCP”Remove-NetIPAddress -InterfaceAlias "<<INTERFACE_ALIAS>>" -IPAddress "<<IP_ADDRESS>>" -Confirm:$falseSet-NetIPInterface -InterfaceAlias "<<INTERFACE_ALIAS>>" -Dhcp EnabledConclusion
Section titled “Conclusion”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.