Information Technology Reference
In-Depth Information
Using a Command-Line Interface
The following command configures two DNS servers for the NIC associated with your local
area connection. In the first command, you'll specify that you're configuring static DNS server
information and supply the primary DNS server's IP address. In the second command, you're
simply adding an additional DNS server for redundancy. Modify the name of the connection
(
Local Area Connection
in our example) and the IP addresses of the DNS servers to fit your
environment.
> netsh interface ip set dns name = "Local Area Connection"
source = static addr = 192.168.1.151
> netsh interface ip add dns name = "Local Area Connection"
addr = 192.168.1.152
■
Note
Using
add dns
here will append the second DNS server to the end of the DNS search order.
The next recipe will discuss changing the search order.
Using the Registry
To configure the DNS servers used for name resolution, set the following Registry value:
[HKey_Local_Machine\System\CurrentControlSet\Services\Tcpip\Parameters\]
"NameServer" = REG_SZ:"
<IP Address>
"
■
Note
You can enter multiple IP addresses in this key, separating the addresses with spaces.
Using VBScript
This code example will configure the local computer with two DNS servers:
192.168.1.151
and
192.168.1.152
. To adjust this script for your environment, simply enter the appropriate values
in the
arrDNSServers
array.
' ------ SCRIPT CONFIGURATION ------
strComputer = "."
arrDNSServers = Array("192.168.1.151", "192.168.1.152")
' --------- END CONFIGURATION ------
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set Nics = objWMIService.ExecQuery _
("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")