diff options
author | Erich Eckner <erich.eckner.ext@bestsecret.com> | 2024-04-14 15:46:07 +0200 |
---|---|---|
committer | Erich Eckner <erich.eckner.ext@bestsecret.com> | 2024-04-14 15:46:07 +0200 |
commit | e7299898533f5d40d24df7f0ced433d3ee16b039 (patch) | |
tree | 8cb4e5b7519fd6fef4fcd2240032fb282e55d86b | |
parent | bc96082875fe873472ecf63c91cbfc6a6c9776a8 (diff) | |
download | arp-ddns-e7299898533f5d40d24df7f0ced433d3ee16b039.tar.xz |
arp-ddns soweit fertig
-rwxr-xr-x | arp-ddns | 38 |
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 |