Showing posts with label dns suffix. Show all posts
Showing posts with label dns suffix. Show all posts

Friday, January 23, 2009

Add Connection Specific dns suffix through command line

There is no direct command available in windows to add connection specific dns suffix for a particylar network connectin. However, one can achieve this by writing windows scripts.

The following snippet will add connection-specific dns suffix to a specific local are network connection. Copy the snippet and save it to a file say setdnssuffix.wsf and run as wscript setdnssuffix.wsf /DNSDomainSuffix:"mysuffix.com" on command prompt. here "mysuffix.com" is dns suffix need to be added.


You can download the script at SetDnsSuffix
< language="VBScript">
Public DNSDomainSuffix
Set colNamedArguments =WScript•Arguments.Named
DNSDomain = colNamedArguments.Item ("DNSDomainSuffix")
NetConnName = colNamedArguments.Item("netConnName")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapter")
For Each objItem in colItems
If Not IsNull(objItem.NetConnectionID) Then
if objItem.NetConnectionID = NetConnName Then
strMacAddress = objItem.MacAddress
end if
End If
Next
call ExecuteDnsSuffix (WMIEchoStr)
Function ExecuteDnsSuffix(WMIEchoStr)
strComputer = "•"
Set objWMIService = GetObject("winmgmts:"
& "{impersonationLevel=impersonate}!¯\\" & strComputer & "\root\cimv2")
Set colNetCards = objWMIService.ExecQuery –
("Select * From Win32–NetworkAdapterConfiguration Where IPEnabled =True")
For Each objNetCard in colNetCards
ExecuteDnsSuffix=objNetCard•SetDNSDomain(DNSDomain)
Next
WMIEchoStr=DNSDomain
End Function
<\script>
<\job>

Wednesday, January 21, 2009

Add DNS suffix search list through command prompt

There are many ways to enable DNS suffix search list group policy in a DNS Client. One method is to create DNS suffix search list is through registry key "SearchList".

1. Assume the DNS suffixes to be added are "myrootdns1.com" and "myrootdns.com". Then the following command adds DNS suffix search list registry key "SearchList" through command prompt.

reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" /v searchlist /t REG_MULTI_SZ /d myrootdns1.com, myrootdns.com /f




To check the Suffix SearchList working or not do the following
1. Assume the target machine name to which the dns suffix search list is "dnsserver"
2. Run the following command to query the name "dnsserver".
nslookup dnsserver



You can verify order of dns queries for the name "dnsserver" by looking in to the dns.log log file located at %systemroot%\system32\dns\dns.log (generally at C:\windows\system32\dns\dns.log) at "dnsserver" host.

Set of suffix search list items to be added is unlimited. It is not possible to update, edit or modify the existing Suffix Search list through command prompt. However, you can change or overwrite the existing suffix search list with the new one.

Design by infinityskins.blogspot