Skip to content

Commit

Permalink
get rid of grep and filter with dig
Browse files Browse the repository at this point in the history
  • Loading branch information
Emzy committed Mar 10, 2023
1 parent 8f06770 commit 0436cae
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions contrib/dnsupdate
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
set -euo pipefail

# Zone to request from bintcoin-seeder
ZONE=dnsseed.example.com
ZONE=dnsseed.emzy.de
# Filters to fetch
FILTERS='x1 x5 x9 xd x49 x400 x404 x408 x40c x448'

Expand All @@ -17,25 +17,24 @@ FILTERS='x1 x5 x9 xd x49 x400 x404 x408 x40c x448'
echo update delete ${ZONE} a
echo update delete ${ZONE} aaaa
for proto in A AAAA ; do
dig -t ${proto} -p 5353 @127.0.0.1 ${ZONE} | \
grep -i "^${ZONE}.*A" | \
awk '{ print "update add "$1" 3600 "$4" "$5"" }'
dig +noall +answer -t ${proto} -p 15353 @52.37.101.214 ${ZONE} | \
awk '{ print "update add "$1" 3600 "$4" "$5"" }'

done
echo send
) | \
nsupdate -v

# Fetch and update A and AAAA records of all available FILTER domain names
for filter in ${FILTERS} ; do
(
(
echo server localhost
echo zone ${ZONE}
echo update delete ${filter}.${ZONE} a
echo update delete ${filter}.${ZONE} aaaa
for proto in A AAAA ; do
dig -t ${proto} -p 5353 @127.0.0.1 ${filter}.${ZONE} | \
grep -i "^${filter}.*A" | \
awk '{ print "update add "$1" 3600 "$4" "$5"" }'
dig +noall +answer -t ${proto} -p 15353 @52.37.101.214 ${filter}.${ZONE} | \
awk '{ print "update add "$1" 3600 "$4" "$5"" }'
done
echo send
) | \
Expand Down

0 comments on commit 0436cae

Please sign in to comment.