▼目次
▼目標(ゴール)
VMware Workstation Pro上にUbuntu 24.04(仮想マシン)を構築し、DockerコンテナとしてPowerDNS Authoritative Server (pdns-auth)とPowerDNS Admin (pdns-admin)を構築するまでを実施します。
▼用語
※※ 執筆中。。※※
▼システム要件
構成
コンポーネント構成
- ①自宅デスクトップPC
- ②Ubuntuサーバ
- ③PowerDNS Authoritativeサーバ(コンテナ)
- ④PowerDNS Adminサーバ(コンテナ)
構成図
導入ソフトウェア
①自宅デスクトップPC
ソフトウェア | バージョン | 備考 |
---|---|---|
Windows11 | Windows 11 Home 24H2 | - |
VMware(R) Workstation 17 Pro | 17.6.2 build-24409262 | - |
②Ubuntuサーバ
ソフトウェア | バージョン | 備考 |
---|---|---|
Ubuntu | 24.04.2 LTS (Noble Numbat) | - |
Docker | Docker version 28.2.2, build e6534b4 | - |
Docker Compose | Docker Compose version v2.36.2 | - |
③PowerDNS Authoritativeサーバ(コンテナ)
ソフトウェア | バージョン | 備考 |
---|---|---|
PowerDNS Authoritative Server (pdns-auth) | PowerDNS Authoritative Server 4.9.5 | - |
④PowerDNS Adminサーバ(コンテナ)
ソフトウェア | バージョン | 備考 |
---|---|---|
PowerDNS Admin (pdns-admin) | ※不明 | - |
必要スペック(最小)
※あくまでも起動するために必要最低限のスペックであり、必要スペックは場合によって変わります。(自宅デスクトップPCは使用しているPCのスペックを記載しています。)
①自宅デスクトップPC
コンポーネント | CPU | RAM | Root Disk | Data Disk |
---|---|---|---|---|
自宅デスクトップPC | AMD Ryzen 7 3700X 8-Core Processor (3.60 GHz) | 64.0GB | 500GB | 4TB (SSD) |
②Ubuntuサーバ
コンポーネント | CPU | RAM | Root Disk | Data Disk |
---|---|---|---|---|
Ubuntu | 2コア | 4GB | 25GB | ※任意 |
③PowerDNS Authoritativeサーバ(コンテナ)
コンポーネント | CPU | RAM | Root Disk | Data Disk |
---|---|---|---|---|
PowerDNS Authoritative Server (pdns-auth) | 2 コア | 2 GB | 32GB | ※任意 |
④PowerDNS Adminサーバ(コンテナ)
コンポーネント | CPU | RAM | Root Disk | Data Disk |
---|---|---|---|---|
PowerDNS Admin (pdns-admin) | ※不明 | ※不明 | ※不明 | ※任意 |
スペック参考資料
Ubuntu
help.ubuntu.comPowerDNS Authoritative
docs.cloudblue.com
各種パラメータ設定
※ (★)はデフォルト値になります。
①自宅デスクトップPC
ホスト名 | IPv4/プレフィックス長 | デフォルトGW | DNS | NTP | プロキシ |
---|---|---|---|---|---|
(★) - |
192.168.1.50/24 | 192.168.1.30 | 8.8.8.8 | (★) time.windows.com |
(★) - |
②Ubuntuサーバ
ホスト名 | IPv4/プレフィックス長 | デフォルトGW | DNS | NTP | プロキシ |
---|---|---|---|---|---|
pdns | 192.168.1.110/24 | 192.168.1.30 | 8.8.8.8 | (★) ntp.ubuntu.com |
(★) - |
③PowerDNS Authoritativeサーバ(コンテナ)
ホスト名 | IPv4/プレフィックス長 | デフォルトGW | DNS | NTP | プロキシ |
---|---|---|---|---|---|
- | 192.168.1.121/24 | 192.168.1.30 ※macvlanで設定 |
(★) - |
(★) ※Dockerホスト(Ubuntuサーバ)の時刻共有 |
(★) - |
④PowerDNS Adminサーバ(コンテナ)
ホスト名 | IPv4/プレフィックス長 | デフォルトGW | DNS | NTP | プロキシ |
---|---|---|---|---|---|
- | 192.168.1.122/24 | 192.168.1.30 ※macvlanで設定 |
(★) - |
(★) ※Dockerホスト(Ubuntuサーバ)の時刻共有 |
(★) - |
ファイアウォール設定
①自宅デスクトップPC
ポート/プロトコル | サービス | 送信元(src) | 送信先(dest) | 備考 | |
---|---|---|---|---|---|
In | - | - | - | - | - |
Out | - | - | - | - | - |
②Ubuntuサーバ
ポート/プロトコル | サービス | 送信元(src) | 送信先(dest) | 備考 | |
---|---|---|---|---|---|
In | - | - | - | - | - |
Out | - | - | - | - | - |
③PowerDNS Authoritativeサーバ(コンテナ)
ポート/プロトコル | サービス | 送信元(src) | 送信先(dest) | 備考 | |
---|---|---|---|---|---|
In | 53/tcp | - | - | - | - |
53/udp | - | - | - | - | |
8081/tcp | - | - | - | - | |
Out | - | - | - | - | - |
④PowerDNS Adminサーバ(コンテナ)
ポート/プロトコル | サービス | 送信元(src) | 送信先(dest) | 備考 | |
---|---|---|---|---|---|
In | 80/tcp | - | - | - | - |
Out | - | - | - | - | - |
▼構築手順
VMware Workstation Pro上でUbuntu構築
- 以下過去記事を参考にUbuntuを構築します。(以下過去記事はvSphere ESXi 8上で構築していますが、本記事ではVMware Workstation Pro上で構築しています。) tokoro10.net
Ubuntuのsshサービス起動
- VMware Workstation Proのコンソールにて、sshサービスをインストールし起動します。(Ubuntuではデフォルトでsshサービスが入っていないため)
その後、Teraterm等でssh接続します。tokoro10nu@pdns:~$ sudo su - root@pdns:~# apt update root@pdns:~# apt install -y ssh root@pdns:~# systemctl start ssh root@pdns:~# systemctl enable ssh root@pdns:~# systemctl status ssh
Dockerサービスの起動
curlをインストールします。
root@pdns:~# apt install curl
Dockerの公式GPG鍵をUbuntuに登録します。
root@pdns:~# install -m 0755 -d /etc/apt/keyrings root@pdns:~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg root@pdns:~# chmod a+r /etc/apt/keyrings/docker.gpg
Ubuntu 24.04(Noble Numbat)用のDocker公式APTリポジトリを追加します。
root@pdns:~# echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
パッケージ一覧を更新します。
root@pdns:~# apt update
Docker CE と公式 Compose/Buildx プラグイン等のパッケージをインストールします。
root@pdns:~# apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin sqlite3
以下コマンドにて動作確認をします。
root@pdns:~# docker --version root@pdns:~# docker compose version
PowerDNSの構築
PowerDNS Authoritative Server (pdns-auth)とPowerDNS Admin (pdns-admin)のための永続ボリューム用ディレクトリを作成します。
root@pdns:~# mkdir -p /srv/pdns/{auth,admin}/{config,logs,data} root@pdns:~# mkdir -p /srv/pdns/auth/schema
スキーマ作成用SQLファイルを作成します。(ファイルの中身は「PowerDNS_Auth_on_Ubuntu/schema.sql at main · tokoro10nu/PowerDNS_Auth_on_Ubuntu · GitHub」になります。内容自体は「Generic SQLite 3 backend — PowerDNS Authoritative Server documentation」の内容そのままです。)
root@pdns:~# vi /srv/pdns/auth/schema/schema.sql
作成したschema.sqlを使用し、初期のテーブル定義をデータベースに流し込みます。
root@pdns:~# sqlite3 /srv/pdns/auth/data/pdns.sqlite3 < /srv/pdns/auth/schema/schema.sql root@pdns:~# sqlite3 /srv/pdns/auth/data/pdns.sqlite3 'SELECT name FROM sqlite_master WHERE type="table";'
PowerDNS Authoritative Server (pdns-auth)とPowerDNS Admin (pdns-admin)のための永続ボリューム用ディレクトリ配下に適切な権限を設定します。
- 「953:953」は、pdns-authコンテナが内部で使う「ユーザID:グループID」
- 「100:101」は、pdns-adminコンテナが内部で使う「ユーザID:グループID」
root@pdns:~# chown -R 953:953 /srv/pdns/auth/{data,logs} # pdns-auth UID/GID root@pdns:~# chown -R 100:101 /srv/pdns/admin/{data,logs} # pdns-admin UID/GID
docker-compose.ymlを作成します。(ファイルの中身は「PowerDNS_Auth_on_Ubuntu/docker-compose.yml at main · tokoro10nu/PowerDNS_Auth_on_Ubuntu · GitHub」になります。)
root@pdns:~# vi /srv/pdns/docker-compose.yml
外部 LAN 用にmacvlanを作成します。(※ ens33 は 仮想マシンUbuntu の NICです。)
root@pdns:~# docker network create pdns_lan \ --driver macvlan \ --subnet 192.168.1.0/24 \ --gateway 192.168.1.30 \ --ip-range 192.168.1.120/29 \ -o parent=ens33
コンテナを起動します。
root@pdns:~# cd /srv/pdns root@pdns:/srv/pdns# docker compose up -d
内部ブリッジから疎通テストをします。
root@pdns:/srv/pdns# docker run --rm --network pdns_internal curlimages/curl -s -H 'X-API-Key: changeme' http://auth:8081 /api/v1/servers | head Unable to find image 'curlimages/curl:latest' locally latest: Pulling from curlimages/curl f18232174bc9: Pull complete 0840d8ec766c: Pull complete bd9ddc54bea9: Pull complete Digest: sha256:d43bdb28bae0be0998f3be83199bfb2b81e0a30b034b6d7586ce7e05de34c3fd Status: Downloaded newer image for curlimages/curl:latest [{"autoprimaries_url": "/api/v1/servers/localhost/autoprimaries{/autoprimary}", "config_url": "/api/v1/servers/localhost/config{/config_setting}", "daemon_type": "authoritative", "id": "localhost", "type": "Server", "url": "/api/v1/servers/localhost", "version": "4.9.5", "zones_url": "/api/v1/servers/localhost/zones{/zone}"}]root@pdns-VM:/srv/pdns#
ドメインとレコードの追加
http://192.168.1.122:8000/へアクセスし、【Create an account】をクリックします。
アカウント情報を入力し、【Register】をクリックします。
前手順で作成したアカウント情報を入力し、【Sign in】をクリックします。
【PDNS Settings】画面にて、以下項目を入力し、【Update】をクリックします。
- PDNS API URL:http://auth:8081
- PDNS API KEY:changeme
- PDNS VERSION:※変更なし
【New Domain】>【Create new domain】画面にて、ドメイン名を入力し、【Submit】をクリックします。
【Dashboard】画面にて、前手順で作成したドメインが表示されることを確認し、【Manage】をクリックします。
【Manage domain: xxx.xxx】画面にて、【Add Record+】をクリックします。追加されたレコードに以下項目を入力し、【Apply Changes】をクリックします。
デスクトップPC側から「nslookup」コマンドによってAレコードが取得できることを確認します。(※dockerホスト側(Ubuntuサーバ)からはmacvlanを経由して通信できないためデスクトップPCから確認しています。)