summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xarp-ddns38
1 files changed, 38 insertions, 0 deletions
diff --git a/arp-ddns b/arp-ddns
new file mode 100755
index 0000000..e9e7ebf
--- /dev/null
+++ b/arp-ddns
@@ -0,0 +1,38 @@
+#!/bin/bash
+
+cd "$(dirname "$(readlink -e "$0")")"
+
+. ./arp-ddns.conf
+
+echo nmap -sn $(
+ sipcalc $(
+ for dev in "${devs[@]}"; do
+ ip -4 -o addr show dev "$dev"
+ done \
+ | awk '{print $4}'
+ ) \
+ | awk '
+ $1 == "Network" && $2 == "address" && $3 == "-" {print $4}
+ $1 == "Network" && $2 == "mask" && $3 == "(bits)" && $4 == "-" {print $5}
+ ' \
+ | sed '
+ N
+ s,\n,/,
+ '
+) >/dev/null
+
+join -1 1 -2 2 -o 1.2,2.1,1.3 <(
+ printf '%s\n' "${hosts[@]}" \
+ | sort -k1,1
+) <(
+ arp -a \
+ | cut -d' ' -f2,4 \
+ | sort -k2,2 \
+ | tr -d '()'
+) \
+| while read -r host ip key; do
+ if dig +short ${host}.ddns.eckner.net A | grep -qxF "${ip}"; then
+ continue
+ fi
+ curl -Ss 'https://eckner.net/ddns.php?i='"${key}"'&address='"${ip}"
+done