LoginSignup
0

More than 1 year has passed since last update.

posted at

updated at

Unboundのビルド方法(1.10.1版)

環境

  • Ubuntu 20.04
  • Python 2.7

1, ソースコードを入手する

wget https://github.com/NLnetLabs/unbound/archive/release-1.10.1.tar.gz
tar -xzvf release-1.10.1.tar.gz
cd release-1.10.1

1行目がソースコードを取得し、2行目で解凍し、3行目で解凍したディレクトリに移動します。

2, 必要なモジュールをインストールする

sudo apt install python2.7 python-dev swig libssl libsystemd-dev
sudo ln /usr/bin/python2.7 /usr/bin/python

2行目でシンボリックリンクを貼らないと、configureでエラーが発生します。

3, configureを実行する

./configure --prefix=/usr/ --enable-systemd --enable-cachedb --with-pythonmodule 

4, make installする

make install

少し時間がかかるので、Twitterでも見て待ってましょう。

ビルド完了後、何もエラーが起こらなければ完了です。

5, セットアップする

5-1, ld.so.confを編集

共有ライブラリを使用可能にするために、/etc/ld.so.confファイルを編集する必要があります。
/usr/lib/etc/ld.so.confに追加して下さい。

5-2, ユーザー・グループを作成

グループunboundと、ユーザーunboundを作成します。このユーザーは、Unboundの設定ファイルを読み込んだりする際に使用されます。

groupadd unbound
useradd -g unbound -d /usr/etc/unbound -s /bin/false unbound

5-3, 設定ファイルを編集

Unboundの設定ファイルは、/usr/etc/unbound/unbound.confです。
少なくとも、以下の設定は追加しておいたほうがいいかもしれません。
chownは必ず設定しておいて下さい。設定しないと、エラーが発生します。

unbound.conf
server:
  verbosity: 1
  chroot: ""
  module-config: "validator iterator"

Pythonモジュールを使用する場合は、以下のようにします。

unbound.conf
server:
  verbosity: 1
  chroot: ""
  module-config: "validator python iterator"

python:
  python-script: "/your/script/file.py"

5-4, 設定ファイルの所有者を変更

現段階で、グループunbound、またはユーザーunboundが設定ファイルを読み込めないので、設定ファイルの所有者を変更します。

chown -R unbound:unbound /usr/etc/unbound/

6, 起動する

以下のコマンドで起動できます。

systemctl start unbound

7, アンインストール

ソースコードをビルドしたディレクトリまで戻り、

make uninstall

と入力するとアンインストールできます。
なお、この操作によって設定ファイルは削除されないので、手動で削除する必要があります。

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
What you can do with signing up
0