0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DNS のルートヒントを更新するスクリプト

Posted at

何故、こんなスクリプトを書いたのか、全く覚えちょらんのだが、折角じゃけ供養しておくw
実行時にはスイッチとか一切なく、dns/bind* とか dns/unbound のインスコして named.root1が居るディレクトリ上で動かせば大丈夫な簡単レシピ✌
アプデが有った時だけ syslog を汚しに行く、とても大人しい仕様となっちょりますけん、他のファイルの取得でタイムスタンプ比較出来んファイルを更新確認しおる際にはひな形に出来そうじゃけ、何なりと参考になると嬉しいのぉ😷
ファイルのパーミッションは配慮しちょりませんけぇ、必要であれば chown を追記するか、実行権限をヒントファイルが読書き出来る権限で実行しんさいな✌

因みに、現在このスクリプトを動かすと、cron で毎日実行しおると、毎回更新されちゃりますけん、まるっと使うんは止めんさいや💦

GET_HINTZONE.sh
#!/bin/sh
N=$(basename $0)
#unset -v HTTP_PROXY

# Check if named.root exists
if test ! -f named.root
        then
                echo Not Found.
                exit 1
fi

# Get the old SOA version
OLD_SOA=$(grep "related version" named.root | awk -F: '{print$2}' | tr -d ' ')

# Download the new named.cache file
fetch -qm ftp://FTP.INTERNIC.NET/domain/named.cache
ret=$?

if test ${ret} -ne 0
        then
                echo Not Found.
                exit ${ret}
fi

# Get the new SOA version
NEW_SOA=$(grep "related version" named.cache | awk -F: '{print$2}' | tr -d ' ')

# Compare and update if the new SOA is greater
if test ${OLD_SOA} -lt ${NEW_SOA}
        then
                logger $N": ZoneRenew. "${OLD_SOA}" to "${NEW_SOA}
                mv named.cache named.root${NEW_SOA}
                unlink named.root
                ln -s named.root${NEW_SOA} named.root
        else
                unlink named.cache
fi

exit 0
  1. https://www.nic.ad.jp/ja/newsletter/No45/0800.html

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?