
IP Configuration with NetSh
A quick guide to configuring IP address settings with netsh.
1 min read
Sometimes you need to configure IP addresses from the command line, for example on Server Core installations. The first step is usually to look up the ID (or index) or the name of the network interface you want:
netsh interface ipv4 show interfaces
With the index (column “Idx”) or name you just looked up, you can configure the IP address of the network card. The example sets a static address first, then switches back to DHCP:
netsh interface ipv4 set address name=ethernet source=static address=10.0.0.10 mask=255.255.255.0 gateway=10.0.0.254
netsh interface ipv4 set address name=ethernet source=dynamic
A static IP configuration usually also needs DNS servers:
netsh interface ipv4 add dnsserver name=ethernet address=10.0.0.1 index=1
netsh interface ipv4 add dnsserver name=ethernet address=10.0.0.2 index=2
Note: “index=” here refers to the order of the DNS servers.