ค้นหาเว็บไซต์

Arpwatch - ตรวจสอบกิจกรรมอีเทอร์เน็ตใน Linux


Arpwatch เป็นโปรแกรมซอฟต์แวร์คอมพิวเตอร์โอเพ่นซอร์สที่ช่วยให้คุณสามารถตรวจสอบกิจกรรมการรับส่งข้อมูล Ethernet (เช่น การเปลี่ยน IP และ ที่อยู่ MAC) บนเครือข่ายของคุณและรักษาฐานข้อมูลการจับคู่ที่อยู่อีเธอร์เน็ต/IP

โดยจะสร้างบันทึกการจับคู่ข้อมูลที่อยู่ IP และ MAC ที่สังเกตเห็น พร้อมด้วยการประทับเวลา เพื่อให้คุณสามารถดูได้อย่างรอบคอบเมื่อกิจกรรมการจับคู่ปรากฏบนเครือข่าย นอกจากนี้ยังมีตัวเลือกในการส่งรายงานทางอีเมลไปยังผู้ดูแลระบบเครือข่ายเมื่อมีการเพิ่มหรือเปลี่ยนแปลงการจับคู่

เครื่องมือ Arpwatch มีประโยชน์อย่างยิ่งสำหรับ ผู้ดูแลระบบเครือข่าย ในการเฝ้าดู กิจกรรม ARP เพื่อตรวจจับ การปลอมแปลง ARP หรือสิ่งที่ไม่คาดคิด การแก้ไขที่อยู่ IP/MAC

การติดตั้ง Arpwatch ใน Linux

เครื่องมือ Arpwatch ไม่ได้รับการติดตั้งบน Linux คุณต้องใช้ตัวจัดการแพ็คเกจเริ่มต้นเพื่อติดตั้งจากที่เก็บข้อมูลของระบบดังที่แสดง

sudo apt install arpwatch             [On Debian, Ubuntu and Mint]
sudo yum install arpwatch             [On RHEL/CentOS/Fedora and Rocky/AlmaLinux]
sudo emerge -a net-analyzer/arpwatch  [On Gentoo Linux]
sudo apk add arpwatch                 [On Alpine Linux]
sudo pacman -S arpwatch               [On Arch Linux]
sudo zypper install arpwatch          [On OpenSUSE]    

เมื่อติดตั้งแล้ว คุณจะสามารถดูไฟล์ arpwatch ที่สำคัญที่สุดได้ ตำแหน่งของไฟล์จะแตกต่างกันเล็กน้อยขึ้นอยู่กับระบบปฏิบัติการของคุณ

  • /usr/lib/systemd/system/arpwatch – บริการ arpwatch สำหรับการเริ่มต้นหรือหยุด daemon
  • /etc/sysconfig/arpwatch – นี่คือไฟล์การกำหนดค่า arpwatch หลัก
  • /usr/sbin/arpwatch – คำสั่งไบนารีเพื่อเริ่มและหยุดเครื่องมือผ่านเทอร์มินัล
  • /var/lib/arpwatch/arp.dat – นี่คือไฟล์ฐานข้อมูลหลักที่บันทึกที่อยู่ IP/MAC
  • /var/log/messages – ไฟล์บันทึกที่ arpwatch เขียนการเปลี่ยนแปลงหรือกิจกรรมที่ผิดปกติไปยัง IP/MAC

ตอนนี้ให้รันคำสั่งต่อไปนี้เพื่อเริ่มบริการ arpwatch

systemctl enable arpwatch
systemctl start arpwatch
systemctl status arpwatch

วิธีใช้คำสั่ง Arpwatch ใน Linux

หากต้องการดูอินเทอร์เฟซเฉพาะ ให้พิมพ์คำสั่งต่อไปนี้ด้วย -i และชื่ออุปกรณ์

arpwatch -i eth0

ดังนั้นเมื่อใดก็ตามที่เสียบปลั๊ก MAC ใหม่หรือ IP เฉพาะเปลี่ยนที่อยู่ MAC ของเขาบนเครือข่าย คุณจะสังเกตเห็นรายการ syslog ใน '/var/log/syslog' หรือ '/ var/log/message' โดยใช้คำสั่ง tail

tail -f /var/log/messages
ผลลัพธ์ตัวอย่าง
Apr 15 12:45:17 tecmint arpwatch: new station 172.16.16.64 d0:67:e5:c:9:67
Apr 15 12:45:19 tecmint arpwatch: new station 172.16.25.86 0:d0:b7:23:72:45
Apr 15 12:45:19 tecmint arpwatch: new station 172.16.25.86 0:d0:b7:23:72:45
Apr 15 12:45:19 tecmint arpwatch: new station 172.16.25.86 0:d0:b7:23:72:45
Apr 15 12:45:19 tecmint arpwatch: new station 172.16.25.86 0:d0:b7:23:72:45

ผลลัพธ์ข้างต้นจะแสดงเวิร์กสเตชันใหม่ หากมีการเปลี่ยนแปลงใดๆ คุณจะได้รับผลลัพธ์ดังต่อไปนี้

Apr 15 12:45:17 tecmint arpwatch: changed station 172.16.16.64 0:f0:b8:26:82:56 (d0:67:e5:c:9:67)
Apr 15 12:45:19 tecmint arpwatch: changed station 172.16.25.86 0:f0:b8:26:82:56 (0:d0:b7:23:72:45)
Apr 15 12:45:19 tecmint arpwatch: changed station 172.16.25.86 0:f0:b8:26:82:56 (0:d0:b7:23:72:45)
Apr 15 12:45:19 tecmint arpwatch: changed station 172.16.25.86 0:f0:b8:26:82:56 (0:d0:b7:23:72:45)
Apr 15 12:45:19 tecmint arpwatch: changed station 172.16.25.86 0:f0:b8:26:82:56 (0:d0:b7:23:72:45)

คุณยังสามารถตรวจสอบตาราง ARP ปัจจุบันได้โดยใช้คำสั่งต่อไปนี้

arp -a
ผลลัพธ์ตัวอย่าง
linux-console.net (172.16.16.94) at 00:14:5e:67:26:1d [ether] on eth0
? (172.16.25.125) at b8:ac:6f:2e:57:b3 [ether] on eth0

หากคุณต้องการส่งการแจ้งเตือนไปยังรหัสอีเมลที่คุณกำหนดเอง ให้เปิดไฟล์การกำหนดค่าหลัก '/etc/sysconfig/arpwatch' และเพิ่มอีเมลตามที่แสดงด้านล่าง

-u <username> : defines with what user id arpwatch should run
-e <email>    : the <email> where to send the reports
-s <from>     : the <from>-address
OPTIONS="-u arpwatch -e [email  -s 'root (Arpwatch)'"

นี่คือตัวอย่างรายงานทางอีเมลเมื่อมีการเชื่อมต่อ MAC ใหม่

        hostname: centos
      ip address: 172.16.16.25
       interface: eth0
ethernet address: 00:24:1d:76:e4:1d
 ethernet vendor: GIGA-BYTE TECHNOLOGY CO.,LTD.
       timestamp: Monday, April 15, 2022 15:32:29

นี่คือตัวอย่างรายงานทางอีเมล เมื่อ IP เปลี่ยนที่อยู่ MAC ของเขา

            hostname: centos
          ip address: 172.16.16.25
           interface: eth0
    ethernet address: 00:56:1d:36:e6:fd
     ethernet vendor: GIGA-BYTE TECHNOLOGY CO.,LTD.
old ethernet address: 00:24:1d:76:e4:1d
           timestamp: Monday, April 15, 2022 15:43:45
  previous timestamp: Monday, April 15, 2022 15:32:29 
               delta: 9 minutes

ดังที่คุณเห็นข้างต้น โดยจะบันทึก ชื่อโฮสต์, ที่อยู่ IP, ที่อยู่ MAC, ชื่อผู้ขาย และ การประทับเวลา

สำหรับข้อมูลเพิ่มเติม โปรดดูที่หน้า man arpwatch โดยกด 'man arpwatch' บนเทอร์มินัล

man arpwatch