This module is provided in order to give network administrators further knowledge about the systems that are part of their network, providing information about changes that computers connected to the network have suffered.
It grabs some allowed IPs from the OpenNAC database (more precisely from the systems table), and passes them to nmap, which is going to perform a scan. The results of this scan are saved to an XML file which is then parsed and these results are used to populate some tables which form part of the OpenNAC inventory system. The module logs to syslog if there are discrepancies between the current scan and information stored in the database. If there are differences it logs what has changed and makes the necessary corrections to the database. The tables used by port_scan are:
The tables protocols and services are lookup tables. They contain descriptions of protocols and services related to a certain port.
The table subnets contains definitions of subnetworks that port_scan is allowed to scan.
The table nac_hostscanned contains general information (IP address, hostname, OS) of scanned systems.
The table nac_openports contains information of the services present on each host which is in the nac_hostscanned table.
OpenNAC
Nmap 4.11 or later
This script has 3 modes of operation:
This script also has the switch "--verbose" to activate debugging. Please note that debugging of this script will be redirected to syslog.
Only those computers which fall within the criteria specified in the subnets table will become a strong candidate to be scanned. As said before, this table contains definitions of subnetworks that port_scan is allowed to scan. This was done so because maybe you have lots of subnets in your network, and some of them are behind a firewall, so they can't be accessed and scanning them would be a waste of time and resources. That's why, you need to specify in this table one register per subnet you want to take into account.
/opt/nac/bin/port_scan
/opt/nac/etc/port_scan.inc
/opt/nac/funcs.inc
/opt/nac/scan/
Important: You need to specify first in the subnets table the networks you want to scan.
/opt/nac/bin/port_scan &
/opt/nac/bin/port_scan --scannow
With the GUI you can set the flag for devices you want to scan now.
If you prefer do it by hand, then
update systems set scannow=1 where ...;
/opt/nac/bin/port_scan 192.168.0.1 192.168.0.2 192.168.0.3 ... 192.168.0.254
Since Dec. 22 2008 the EndDevice class contains a new method called "PostScan". What this method does is to set the scannow flag of the system requesting access if and only if this system has not been scanned in the last 7 days.
In a proper configured system, port_scan in scannow mode will run every five minutes. Thus, every five minutes a port_scan will be run and the information about open ports will be up-to-date.
Note that this method was planned to be used by postconnect. For an example of how to use it, please have a look at policy 11.
Please report them in our Development forum:
http://www.freenac.net/phpBB2/viewforum.php?f=2