IP and DNS
Netsh can accomplish many tasks, and one of those is to set a system’s IP address and DNS servers. Like the IPv4 Properties GUI that you’ll find in the full Server 2008 installation, Netsh lets you choose to either assign a static IP address or get IP information from a DHCP server. Using DHCP makes for a simpler command, so let’s start with that:
netsh interface ipv4 set address name="Local Area Connection" source=DHCP
DHCP is the default setting, so it’s more likely that you’ll want to set a static IP address. To do so, assemble a Netsh command on one line as follows:
netsh interface ipv4 set address name="Local Area Connection" source=static address=X.x.x.x mask=255.255.255.0 gateway=X.x.x.x
Notice that the gateway is now optional. Some older versions of Netsh complained if you left the default gateway’s IP address off a Netsh command.
For example, to assign a static IP address of 192.168.2.2 on a /24 network with a default gateway address of 192.168.2.1, you’d type:
netsh int ip set address “local area connection” static 192.168.2.2 255.255.255.0 192.168.2.1
Finally, you’ll want to specify one or more DNS servers’ IP addresses that your Server Core system can use for resolving names. Netsh can do that, but the syntax is a bit unexpected: You use netsh int ip set dns to set the preferred DNS server and netsh int ip add dns to specify your additional choices. The syntax for setting the first DNS server is easier than for setting the IP address:
netsh int ip set dns “local area connection” static 10.50.50.4
Leave a Reply