Sto creando un programma di rete Python e ho bisogno di scoprire tutti gli host utilizzabili sulla rete come telefoni e desktop su Linux. Cosa funziona meglio, NMAP, Arp-Scan, arp, o qualcos'altro?
Ho provato questo per scoprire gli host con NMAP:
nmap -n -sn 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/\(|\)/,""); up = $NF}'
Questo per Arp-Scan:
sudo arp-scan -I wlp1s0 -l
E questo per ARP:
arp -a
Eseguendo ognuno di questi comandi, uno dopo l'altro, ottengo questi risultati:
seth@pixel:~$ sudo arp-scan -I wlp1s0 -l
Interface: wlp1s0, datalink type: EN10MB (Ethernet)
Starting arp-scan 1.9 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)
192.168.1.1 20:e5:2a:04:85:d2 NETGEAR INC.,
192.168.1.3 bc:c8:10:28:6e:38 Cisco SPVTG
192.168.1.4 e4:e0:a6:3f:45:88 (Unknown)
192.168.1.9 d4:f4:6f:25:0f:c3 (Unknown)
192.168.1.16 c0:ee:fb:ef:a0:90 (Unknown)
5 packets received by filter, 0 packets dropped by kernel
Ending arp-scan 1.9: 256 hosts scanned in 2.271 seconds (112.73 hosts/sec). 5 responded
seth@pixel:~$ nmap -n -sn 192.168.1.0/24 | awk '/is up/ {print up}; {gsub (/\(|\)/,""); up = $NF}'
192.168.1.1
192.168.1.3
192.168.1.13
192.168.1.16
seth@pixel:~$ arp -a
? (192.168.1.73) at <incomplete> on wlp1s0
? (192.168.1.14) at <incomplete> on wlp1s0
? (192.168.1.207) at <incomplete> on wlp1s0
? (192.168.1.140) at <incomplete> on wlp1s0
? (192.168.1.77) at <incomplete> on wlp1s0
? (192.168.1.18) at <incomplete> on wlp1s0
? (192.168.1.211) at <incomplete> on wlp1s0
? (192.168.1.144) at <incomplete> on wlp1s0
? (192.168.1.81) at <incomplete> on wlp1s0
? (192.168.1.22) at <incomplete> on wlp1s0
? (192.168.1.215) at <incomplete> on wlp1s0
? (192.168.1.148) at <incomplete> on wlp1s0
? (192.168.1.5) at e4:e0:a6:3e:af:ad [ether] on wlp1s0
? (192.168.1.9) at d4:f4:6f:25:0f:c3 [ether] on wlp1s0
? (192.168.1.4) at e4:e0:a6:3f:45:88 [ether] on wlp1s0
? (192.168.1.16) at c0:ee:fb:ef:a0:90 [ether] on wlp1s0
? (192.168.1.3) at bc:c8:10:28:6e:38 [ether] on wlp1s0
? (192.168.1.3) at bc:c8:10:28:6e:38 [ether] on wlp1s0
Come puoi vedere, arp -a
restituisce il maggior numero di host nel più breve tempo possibile, ma è preciso e affidabile?
Cosa dovrei usare?
Dovrei semplicemente scrivere un semplice script che ping tutti gli host in una data subnet?