使用arp-scan掃描主機的IP與MAC,使用Python加入資料庫
Step1)使用arp-scan掃描區域網路內的主機,需要在同一個網段內,寫一個批次檔,如下,存檔在arp-scan.sh。
#!/bin/sh
today=`/bin/date +%Y%m%d%H%M`
arp-scan --interface=re0 --localnet > /root/arp/vlan20/vlan20-$today.txt
給予執行權限
#chmod 700 arp-scan.sh
編輯/etc/crontab,每小時的20分鐘掃描一次
20 * * * * root /root/arp/arp-scan.sh
Step2)使用Python將資料加入資料庫net