- In Windows PowerShell, run
Get-NetIPInterface
. - Make a note of the number shown in the IfIndex column of the output for your IP interface or the InterfaceDescription string. If your computer has more than one network adapter, make a note of the number or string corresponding to the interface for which you wish to set a static IP address.
- In Windows PowerShell, run
New-NetIPAddress –InterfaceIndex 12 –IPAddress -192.0.2.2 –PrefixLength 24 –DefaultGateway -192.0.2.1
Where:
InterfaceIndex
is the value of IfIndex from Step 2 (in this example, 12)IPAddress
is the static IP address you intend to set (in this example, 192.0.2.2)PrefixLength
is the prefix length (another form of subnet mask) for the IP address you intend to set (in this example, 24)DefaultGateway
is the default gateway (in this example, 192.0.2.1) - In Windows PowerShell, run
Set-DNSClientServerAddress –InterfaceIndex 12 -ServerAddresses 192.0.2.4
Where:
InterfaceIndex
is the value of IfIndex from Step 2ServerAddresses
is the IP address of your DNS server - To add multiple DNS servers, run
Set-DNSClientServerAddress –InterfaceIndex 12 -ServerAddresses 192.0.2.4,192.0.2.5
Where in this example, 192.0.2.4, 192.0.2.5 are both IP addresses of DNS servers
If you need to switch to using DHCP, use the Windows PowerShell command Set-DnsClientServerAddress –InterfaceIndex 12 –ResetServerAddresses
.
Found on technet
Leave a Reply