toolkit/func/core/pkg_network/30-test-arpwatch.sh
2022-11-21 14:10:54 -06:00

24 lines
405 B
Bash

#!/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}"