How can I set "DNS Suffix for this connection:" with a gpo or script?

Answered How can I set "DNS Suffix for this connection:" with a gpo or script?

  • Friday, November 30, 2012 2:28 PM
     
     

    We have several hundred PCs running XP SP3 with all updates that were recently deployed and the "DNS suffix for this connection" in the network property setting was somehow set to our lab domain. (Don't ask me how it got there, all I can do is blame Altiris.)

    We currently in 2003 native mode.

    In group policy I have tried the following to resolve and also test:

    Computer Config\Policies\Admin Templates\Network\DNS Client\Connection-Specific DNS Suffix  - does not work

    Computer Config\Policies\Admin Templates\Network\DNS Client\Primary DNS Suffix - does not work

    Computer Config\Policies\Admin Templates\Network\DNS Client\DNS Suffix Search List - this one works.  I'm using it to test GPO in general.

    The DNS Suffix Search list policy works as advertised.  The other two have no affect.  I am using DHCP so maybe that over rides the Primary DNS Suffix policy?

    Any help would be greatly appreciated.  I'm not much of a scripter, but I can copy and paste with the best of them!

    Thanks,  Tim

All Replies

  • Monday, December 03, 2012 3:19 AM
    Moderator
     
     Answered

    Hi Tim,

    Connection-Specific DNS Suffix policy only applies to Windows XP Professional, this is by design. Only Windows XP Professional will check registry location, HKLM\Software\Policies\Microsoft\Windows NT\DNSClient, for the enty AdapterDomainName.

    Can you try this to workaround:
    Add Connection Specific dns suffix through command line
    http://www.dns-info.blogspot.com/2009/01/add-connection-specific-dns-suffix.html

    Regards,
    Cicely

  • Thursday, December 06, 2012 1:22 PM
     
     

    Thanks for you reply, Cicely.  I've tired that script but I get an error running it and I don't know why. I'm not a scripter so I'll have to switch to a scripting forum. The error I get is:

    Line 1, Char. 11  Expecting a valid name.

    This is line 1:

    <language="VBScript">

    as I'm sure you can see, the opening " is the character.

    Tim


    Tim

  • Thursday, December 06, 2012 3:28 PM
     
     Answered
     
    > <language="VBScript">
     
    The script is incomplete.... this line should read
    <script language="VBScript">
     
    and it lacks a <job name="Blah"> as the very first line because it
    closes with a <\job> which is wrong, too, because closing tags require a
    forward slash, not a backslash.
    Line 3 will not work, too: Set colNamedArguments =WScript•Arguments.Named
    The centered dot has to be a normal punctuation sign. Same is true for
    strComputer = "•"
     
    I don't want to blame the guy who wrote that - but he never tested what
    he published. So indeed I blame him...
     
    I suggest a real cool oneliner instead:
         wmic path win32_networkadapterconfiguration where (ipenabled=true)
    call setdnsdomain "a.b.c"
     
    This is verified and it works. It simply sets a.b.c as a dnsdomain on
    all ip enabled adapters. But as you already mentioned: DHCP options
    usually include the dns suffix, so why do you bother at all? Update your
    DHCP servers and things should be ok...
     
    regards, Martin
     

    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!
    • Marked As Answer by TimTheViking Thursday, December 06, 2012 4:31 PM
    •  
  • Thursday, December 06, 2012 4:18 PM
     
     

    Thanks for the reply, Martin.  I didn't mention that we do have the dns domain set in dhcp, however, it does not set the Primary DNS Suffix setting that I have the problem with.

    Tim


    Tim

  • Thursday, December 06, 2012 4:22 PM
     
     

    Martin, what's the extension of this script.  I tried it as a .vbs but go an error on character 11.  Also, in the post the script is on two lines.  Is that just the forum doing that and it is indeed only one line?  

    Thanks,

    Tim


    Tim

  • Thursday, December 06, 2012 5:40 PM
     
     

    Martin, what's the extension of this script.  I tried it as a .vbs but go an error on character 11.  Also, in the post the script is on two lines.  Is that just the forum doing that and it is indeed only one line?  



    This is the script as posted in the forum - that will NOT work... Shame on whoever posted it, it contains about 10 typos.

    < 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>

    This works - tested :-D Extension must be .wsf
    BTW: Even the commandline he mentions is wrong.
    Post says: wscript setdnssuffix.wsf /DNSDomainSuffix:"mysuffix.com"
    Correct: wscript setdnssuffix.wsf /DNSDomainSuffix:"mysuffix.com" /netconnname:"Local Area Connection"
    And be aware that the value for netconnname is CASE sensitive.

    <job>
    <script language="VBScript">
    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
    call ExecuteDnsSuffix (strMacAddress )
    end if
    End If
    Next

    Function ExecuteDnsSuffix(strMacAddress )
    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>


    NO THEY ARE NOT EVIL, if you know what you are doing: Good or bad GPOs?
    Wenn meine Antwort hilfreich war, freue ich mich über eine Bewertung! If my answer was helpful, I'm glad about a rating!