Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

How To Find/List Remote Unix Servers

by Mitch (Sexton)
on Feb 14, 2003 at 15:49 UTC ( [id://235291]=perlquestion: print w/replies, xml ) Need Help??

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

Hi, I'm just starting out on UNIX and I'm looking for a way to generate a list of remote UNIX servers in an internal network. I know in a Windows environment, because windows machines browse/nbt I can use net view or netdom from a system call or the Win32::NetAdmin module, ex:
Win32::NetAdmin::GetDomainController('', $domain, $pdc); Win32::NetAdmin::GetServers($pdc,$domain,SV_TYPE_ALL, \@server); <br>
I'm looking for a UNIX command or Perl module that will find remote servers without having to read host files or dns servers. Any help would be much appreciated, thanks.

Mitch

Replies are listed 'Best First'.
Re: How To Find/List Remote Unix Servers
by jasonk (Parson) on Feb 14, 2003 at 16:09 UTC

    You can find windows machines because they constantly send out broadcasts identifying themselves. Unix machines generally don't do anything like that, so you will have to use a much more brute-force method. Without reading configuration files, your best bet will probably be to use something like nmap, that can check every ip address on the network to see which ones are used, and try to identify the operating system.

      On a side note, be careful with nmap, especially in a NATed environment. I recently had the joy of dealing with a situation as follows

      An individual produced some code to test a network for hosts reachable, the network was I think a few /22s. The program was executed from behind a firewall/router, so for every test to every IP address, another slot was taken in the NAT table entry. Read X ports * Y hosts * Z networks scanned. Read firewall fall down go boom!. Read network admins very very upset, (spent a day dodging irate network admins spitting fireballs and lightning bolts from every conceivable orifice).

      Moral of the story ... Be very careful playing with nmap, when you don't own the network, or understand all the happenings on your network. And don't be the guy that executed or wrote that code. Cause a whole lot of people will be really really unhappy with you.

      /* And the Creator, against his better judgement, wrote man.c */
      Thanks for the tip, I'll give it a try.
Re: How To Find/List Remote Unix Servers
by Tomte (Priest) on Feb 14, 2003 at 16:12 UTC

    a ping-broadcast (broadcast-ping??) should help, but if you're not the administrator, get out of his/her way quickly after doing that.

    Update:
    This not as brute-force as using nmap, but also not liked. Both approaches will cost you dearly if you are not realy in charge of the network.
    Using the ping-method, use -c2 to get the full list of not filtering/filtered machines with a minimum of traffic.
    If you plan to do this regularly, don't, there's a reason unix sysadmins don't like windows-machines; they are way to verbose...turning unix machines into a coffee-klatsch (hey, found that on leo external link) is kind of rude.

    regards,
    tomte


Re: How To Find/List Remote Unix Servers
by KPeter0314 (Deacon) on Feb 14, 2003 at 16:56 UTC
    I guess the question is: Are you the administrator of these machines?

    If so, you should already know about them and keep a database of them so you know what and why they are. We have had to create a mysql datase and use it to keep track of the 200+ servers that we maintain. It was a lot of work but has been more that well worth the effort. From that list we maintain a status of each server and scripts (shell and perl) that keep track of the configurations to a central webserver.

    If you are just looking for any Unix server thay may be out there on your network I would have to agree that nmap is what you might need but should be used with a lot of caution.

    -Kurt

      Actually, I'm an administrator for the Windows systems. We have created and automated server inventory for our Windows domains and systems. However, I've been recently asked to do the same for the UNIX devices. The UNIX team doesn't have dynamic/semi-dynamic inventory records. I'm trying to get as much background information as possible before working with them. Once I can discover the UNIX servers the rest of the code should be easy accessing and reporting the inventory - OS information.

      Mitch

         If, once you've found the machines, you want to run some sort of inventory system upon each of them, it sounds like you're going about this the wrong way.

         Rather than have one 'client' detect each Unix server - then demand it reports over it's software list/hardware information (or whatever) it seems to make more sense to get each server to send it's details to a "well known" reporting machine.

         This is what I've done upon my machines at work. Each server has SSH setup to allow automatic logins to a lowlevel account upon a spare Linux box.

         Once this is setup it's trivial to write a perl script to install upon each server to write out the machines users/load/package details/etc to a text file, and use 'scp' to store it upon the reporting server.

         The reporting server can then read the details from all hosts, and summerize to a daily email, or present the data interactively with CGI scripts, etc.

         If I've misunderstood your question please feel free to comment..

        Steve
        ---
        steve.org.uk

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://235291]
Approved by krujos
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2024-03-28 10:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found