How to configure TCP/IP settings of a Windows 2008 Server Core installation using netsh.exe tool
First we need to find the current TCP/IP configuration using ipconfig /all command. A sample output is copied below.
C:\>ipconfig /all
Windows IP Configuration
Host Name . . . . . . . . . . . . : WIN-WDFPNLMJU99
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection
Physical Address. . . . . . . . . : 00-0C-29-B3-FC-8D
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::e4b7:3600:b305:af9e%2(Preferred)
Autoconfiguration IPv4 Address. . : 169.254.175.158(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
Tunnel adapter Local Area Connection* 2:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft ISATAP Adapter #2
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
C:\>
Here ipconfig /all command displays two network interfaces. A physical interface (NIC) and an ISATAP (Intra-Site Automatic Tunnel Addressing Protocol) tunneling interface. Here Local Area Connection is using an Automatic Private IP Address (APIPA).
Before start configuring the TCP/IP settings of network interface card, we need to know which interface we need to configure. To know the interface index number, use the netsh command as shown below.
C:\>netsh interface ipv4 show interfaces
Idx Met MTU State Name
--- --- ----- ----------- -------------------
2 10 1500 connected Local Area Connection
1 50 4294967295 connected Loopback Pseudo-Interface 1
Now we want to configure the the following TCP/IP settings to the Local Area Connection.
1) IP Address - 192.168.100.21
2) Subnet Mask - 255.255.255.0
3) Default Gateway - 192.168.100.1
4) Primary DNS Server 192.168.100.12
5) Secondary DNS Server 192.168.100.13
To configure the first three settings run the netsh command as shown below.
C:\>netsh interface ipv4 set address name="2" source=static address=192.168.100.21 mask=255.255.255.0 gateway=192.168.100.1
To configure TCP/IP settings with primary and secondary DNS Server IP address, use the following command.
C:\>netsh interface ipv4 add dnsserver name="2" address=192.168.100.12 index=1
C:\>netsh interface ipv4 add dnsserver name="2" address=192.168.100.13 index=2
The primary DNS server's index is 1, the secondary DNS server's index is 2. Use winsserver instead of DNS Server in above command to configure a WINS server
To remove a DNS Server from the TCP/IP configuration, use the following command.
C:\>netsh interface ipv4 delete dnsserver name="2" address=192.168.1.13
To revert to dynamic IP address, use the following command.
C:\> netsh interface ip set address name="2" dhcp