I've recently updated to a MT-6000 from an old TP-Link router, running the stock fimware (21.02-SNAPSHOT) while i familiarize myself with OpenWrt.
I've been using a shortcut on my phone for a few years that wakes my server remotely, over wan or lan, all i had to do was enable mac binding on the router.
I initially assumed it should be easily able to adapt my solution to the Flint2. For the better part of a week I've scoured the internet looking for a way, and while I've come across the exact issue loads of times, it's often a few years old and there never seems to be a solution.
Eventually, i managed to wake the PC with a magic packet to the WAN but only after I run:
ip neigh replace 192.168.0.100 lladdr 68:05:ca:7f:10:c2 dev br-lan nud permanent
As I've found, PERMANENT static arp doesn't mean immutable. If device is off it stays permanent until i wake it, switching to reachable, stale and failed within 30 minutes of being powered off again.
What I'm thinking is a script that checks the ARP table for the reachable/stale state and just runs the ip neigh command.
Since i can't code and this being a relatively simple script, i thought it safe to use AI to do:
#!/bin/sh
# Configuration
TARGET_MAC="68:05:ca:7f:10:c2"
TARGET_IP="192.168.0.100"
TARGET_DEV="br-lan"
CHECK_INTERVAL=30 # seconds
LOG_TAG="arp-monitor"
log_msg() {
logger -t "$LOG_TAG" "$1"
}
make_permanent() {
ip neigh replace "$TARGET_IP" lladdr "$TARGET_MAC" dev "$TARGET_DEV" nud permanent
if [ $? -eq 0 ]; then
log_msg "Made $TARGET_IP ($TARGET_MAC) permanent"
else
log_msg "Failed to make $TARGET_IP permanent"
fi
}
log_msg "Starting ARP monitor for $TARGET_IP ($TARGET_MAC)"
while true; do
# Get the current state of the target IP
STATE=$(ip neigh show "$TARGET_IP" | grep -i "$TARGET_MAC" | awk '{print $NF}')
if [ -n "$STATE" ]; then
case "$STATE" in
REACHABLE|STALE)
log_msg "Detected state: $STATE for $TARGET_IP"
make_permanent
;;
PERMANENT)
# Already permanent, do nothing
:
;;
*)
# Other states: INCOMPLETE, DELAY, PROBE, FAILED
log_msg "Current state: $STATE for $TARGET_IP"
;;
esac
fi
sleep "$CHECK_INTERVAL"
done
And the startup script /etc/init.d/arp-monitor
#!/bin/sh /etc/rc.common
START=99
STOP=10
USE_PROCD=1
start_service() {
procd_open_instance
procd_set_param command /root/arp-monitor.sh
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
Before i go ahead, Is there a reason this is a bad ideea or would not work as I expect it to?
Thanks