[howto] get the nameserver name?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wiktor Zychla

    [howto] get the nameserver name?

    In my code I have to query the local dns server for some data. however, I
    have no idea how to get the name of the local DNS server.

    could anyone point me the right direction?
    thanks in advance,

    Wiktor Zychla


  • Girish Bharadwaj

    #2
    Re: [howto] get the nameserver name?

    Wiktor Zychla wrote:
    [color=blue]
    > In my code I have to query the local dns server for some data. however, I
    > have no idea how to get the name of the local DNS server.
    >
    > could anyone point me the right direction?
    > thanks in advance,
    >
    > Wiktor Zychla
    >
    >[/color]

    Would System.Net.Dns class help you?

    --
    Girish Bharadwaj

    Comment

    • Wiktor Zychla

      #3
      Re: [howto] get the nameserver name?

      > Would System.Net.Dns class help you?

      If you can help to show me the proper method or property of this class, I
      would be grateful. I make a heavy use of Dns class and didn't find any way
      to get the nameserver name.


      Comment

      • Girish Bharadwaj

        #4
        Re: [howto] get the nameserver name?

        Wiktor Zychla wrote:
        [color=blue][color=green]
        >>Would System.Net.Dns class help you?[/color]
        >
        >
        > If you can help to show me the proper method or property of this class, I
        > would be grateful. I make a heavy use of Dns class and didn't find any way
        > to get the nameserver name.
        >
        >[/color]
        Oh.. Sorry, I was thinking you wanted the services of Dns and not the
        name. If you have enough privileges, you can check the
        "HKEY_LOCAL_MAC HINE\SYSTEM\Cur rentControlSet\ Services\Tcpip\ Parameters"'s
        "NameServer " string.

        --
        Girish Bharadwaj

        Comment

        • Rich Blum

          #5
          Re: [howto] get the nameserver name?

          "Wiktor Zychla" <ieUser@microso ft.com.no.spam> wrote in message news:<ucXTYtKmD HA.2140@TK2MSFT NGP09.phx.gbl>. ..[color=blue][color=green]
          > > Would System.Net.Dns class help you?[/color]
          >
          > If you can help to show me the proper method or property of this class, I
          > would be grateful. I make a heavy use of Dns class and didn't find any way
          > to get the nameserver name.[/color]


          You can use the System.Manageme nt methods:

          class GetDNS
          {
          public static void Main()
          {
          ManagementObjec tSearcher mos = new ManagementObjec tSearcher(
          "SELECT * FROM Win32_NetworkAd apterConfigurat ion WHERE IPEnabled = 'TRUE'");
          ManagementObjec tCollection moc = mos.Get();
          foreach(Managem entObject mo in moc)
          {
          Console.WriteLi ne("Network Card: {0}", mo["Descriptio n"]);
          string[] hosts = (string[])mo["DNSServerSearc hOrder"];
          foreach(string host in hosts)
          Console.WriteLi ne(" DNS host: {0}",host);
          }
          }
          }

          Hope this helps some.

          Rich Blum - Author
          "C# Network Programming" (Sybex)

          "Network Performance Open Source Toolkit" (Wiley)

          Comment

          Working...