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 Jun 21, 2022
1 parent c33e5ef commit 9962295
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}.*[[:space:]]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}.*[[:space:]]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 9962295

Please sign in to comment.