Discovery

From FreeNATS Wiki
Jump to: navigation, search

FreeNATS comes with a PHP command-line only (not web run for timeout reasons) discovery tool. This tool generates XML output suitable for use with the bulk importing tool.

You will usually have to run this tool as a superuser because it uses low level socket operations to ping each host.

Using the Tool

Change to the FreeNATS bin directory (cd /opt/freenats/server/bin for Virtual Appliance users) to run the script. The usage information provided is as follows:

FreeNATS Discovery Tool
Usage: php discover.php <IP/RANGE> [<IP/RANGE> ...] [options]

Goes through IPs or ranges and discovers nodes, outputting an XML file for
import to FreeNATS with the bulk importer.

IPs or Ranges are Specified as:
 10.0.10.1 - single IP address
 10.0.10.1-10.0.10.254 - range of IP addresses
 10.0.10.0/24 - network with numeric netmask
 10.0.10.0/255.255.255.0 - network with IPv4 netmask

Options are:
 --file <filename> - output XML file (defaults to discover.xml)
 --webprobe - do a web probe and add the test if found
 --recorded - set the record data flag for any discovered tests by default

See www.purplepixie.org/freenats for more information.

So for example:

php discover.php 192.168.0.1 --file output.xml

Would try and ping a single IP and if the host was up list it for inclusion. Output would go into output.xml

php discover.php 192.168.0.1 --file output.xml --webprobe

Would do the same thing but also try and connect to http://192.168.0.1/ and add a web time test for this node/URL if successful into the output

php discover.php 192.168.0.1-192.168.0.254

Would do a simple discovery of all IPs between 192.168.0.1 and 192.168.0.254 inclusive and output to the standard discovery.xml file

It is essentially the same as:

php discover.php 192.168.0.0/24
php discover.php 192.168.0.0/255.255.255.0

You can specify multiple IPs and ranges so:

php discover.php 10.0.10.1 10.0.10.123 192.168.0.100-192.168.0.110

Would probe the IPs 10.0.10.1, 10.0.10.123 and all from 192.168.0.100 to 192.168.0.110 inclusive


Using the Output

The output is in standard FreeNATS bulk import format and can be edited by hand if required before being imported into FreeNATS with the bulk importer tool.


Virtual Appliance Example

For example on the FreeNATS virtual appliance you would login to the console and then:

cd /opt/freenats/server/bin
php discover.php 192.168.0.100-192.168.0.200

To discover nodes from 192.168.0.100 to 192.168.0.200 inclusive. This will generate the output the discover.xml

You may then like to edit/check the file - either in the console text editor:

nano discover.xml

Press Control-X then Return to Save and Exit

or upload the file onto a share and edit it in your preferred text editor

smbclient -U username //server/share
enter password when prompted
put discover.xml
quit

then after editing get it back

smbclient -U username //server/share
enter password when prompted
get discover.xml
quit

Once you're happy with the XML file you can do a trial import with:

php import.php discover.xml

And see if any errors are generated etc. To commit the changes do:

php import.php discover.xml --live