Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to find a nice simple wat to find the DNS of the server my script is on

Net::Domain gives me the domain but not the DNS
Net::DNS doesn't help

any suggestions?

Replies are listed 'Best First'.
Re: find DNS of local server
by halley (Prior) on May 12, 2003 at 13:05 UTC

    For clarification, lets see if I'm guessing right.

    • Your script is running on a server S,
    • S sometimes needs to request names from DNS servers,
    • Your script needs the list of DNS servers S may contact.

    If I've divined your question correctly, I still have to guess the operating system.

    Linux and Solaris and most Un*x varieties allow anyone to read the /etc/resolv.conf file, which may include one or two lines beginning with "nameserver". If not, you're going to have to do more legwork.

    Windows NT can list the nameservers if your script can (1) execute and (2) parse the output of the ipconfig command. There may be Win32::* ways to do this more directly.

    --
    [ e d @ h a l l e y . c c ]

      no, I have ten servers and each has the same script on it but needs to do different things depending on which server it is on

      rather than hard coding different server names into the script I want to use just one script, which checks which server it is on and then does the appropriate things

      ie if I am of server1 then do A
      if I am on server2 then do B
      etc
Re: find DNS of local server
by JamesNC (Chaplain) on May 12, 2003 at 11:55 UTC
    what OS are you on? what version of Perl?
      v5.6.1 built for i386-linux