📜 ⬆️ ⬇️

Network Device Detection

Scanning a network with building a list of devices and their properties, such as a list of network interfaces, and then removing data in monitoring systems, if you do not delve into what is happening, it may seem special, computer magic. How does it work - under the cut.


Disclaimer
The author does not have a specialized education associated with the administration of networks, so there are probably inaccuracies and not all that is mentioned is mentioned.

Detection


To detect a device, i.e. determine if there is anything on the selected ip-address, you can apply the following methods:


Collection of information


After the device is detected, you can proceed to gathering information about it.
Using the ARP protocol, you can get a MAC address via ip, and a probable manufacturer can get it (some equipment allows changing the address, so the method is not very reliable). Then you can use the nmap utility, which scans the open ports, compares with its database of fingerprints and makes an assumption about the operating system used, its version and device type.

Getting device type and operating system using nmap
 nmap -O -v 192.168.0.1 Starting Nmap 7.60 ( https://nmap.org ) at 2018-03-04 01:17 RTZ 2 (ceia) Initiating ARP Ping Scan at 01:17 Scanning 192.168.0.1 [1 port] Completed ARP Ping Scan at 01:17, 0.70s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 01:17 Completed Parallel DNS resolution of 1 host. at 01:17, 0.00s elapsed Initiating SYN Stealth Scan at 01:17 Scanning 192.168.0.1 [1000 ports] Discovered open port 80/tcp on 192.168.0.1 Discovered open port 49152/tcp on 192.168.0.1 Discovered open port 1900/tcp on 192.168.0.1 Completed SYN Stealth Scan at 01:17, 0.13s elapsed (1000 total ports) Initiating OS detection (try #1) against 192.168.0.1 Retrying OS detection (try #2) against 192.168.0.1 WARNING: OS didn't match until try #2 Nmap scan report for 192.168.0.1 Host is up (0.00s latency). Not shown: 997 closed ports PORT STATE SERVICE 80/tcp open http 1900/tcp open upnp 49152/tcp open unknown MAC Address: A0:F3:C1:35:21:58 (Tp-link Technologies) Device type: WAP Running: Linux 2.4.X OS CPE: cpe:/o:linux:linux_kernel:2.4.36 OS details: DD-WRT v24-sp1 (Linux 2.4.36) Network Distance: 1 hop 

To obtain more detailed information on the device, you will need one of the following methods:


How it works on the example of Zabbix


As you know, Zabbix can independently discover new devices on the network and automatically poll some of their parameters. This is called - Low Level Discovery .

Device discovery is defined by network discovery rules that combine the detection methods listed earlier, determine whether a device is available and which template to apply to it (the device description is usually examined). The template contains a list of properties that can be obtained from the device, as well as rules for the detection and creation of new, executed on a timer.

In the case of SNMP, this might look something like this: enumerate all the child elements of the 1.3.6.1.2.1.2.2.1.8 node (detection rule) and for each element found (the number placed in {#SNMPINDEX} ) add new metrics set via prototypes of data elements, 1.3.6.1.2.1.2.2.1.10.{#SNMPINDEX} and 1.3.6.1.2.1.2.2.1.16.{#SNMPINDEX} , if they are not already there. Read more here .

In the case of an agent, the rule will look a little different: request one of the discovery properties from the agent, for example system.cpu.discovery , get a list of processors in the form of json

 [ {"NUMBER": 0, "STATUS": "online"}, {"NUMBER": 1, "STATUS": "online"} ] 

and for each element add system.cpu.load[{#CPU.NUMBER}] , if there is no such metric yet. It should be noted that Zabbix-agent allows you to create your own elements ( UserParameter ), which can be requested, and therefore you can easily implement, for example, finding files and tracking their size in a given folder. Read more here .

Conclusion


As you can see everything is quite simple and there is no magic. If you know any other ways to detect devices or get their properties, please report them.

Source: https://habr.com/ru/post/350394/


All Articles