toolkit/func/core/pkg_network/30-test-arpwatch.sh
2021-07-04 23:50:25 -07:00

24 lines
405 B
Bash
Executable File

#!/bin/bash
# defaults
defaultGW=$(ip route | awk '/^default via/ { print $3 }')
arpdat="/var/lib/arpwatch/arp.dat"
if [ -z "${defaultGW}" ]; then
r_log "arpwatch" "There is no default gateway set."
exit
fi
arpwatch
sleep 5
arp -d "${defaultGW}"
sleep 5
ping -i 1 -q -c 5 "${defaultGW}"
killall arpwatch
sleep 3
grep -q "${defaultGW}" "${arpdat}"
r_checkExitStatus $?
cat /dev/null > "${arpdat}"