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 キャッシュサーバに

0
Posted at

突然家庭内 DNS キャッシュサーバを建てたくなること、ありますよね。
そこでちっこいシンクライアントマシンを入手して建てました。

マシン

入手したマシンは Dell Wyse 3040 です。
https://www.dell.com/support/manuals/ja-jp/wyse-3040-thin-client/3040_ug/%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E4%BB%95%E6%A7%98

専用 OS が載っていますが、まぁ x86_64 なマシンです。

CPU は Intel Atom x5-Z8350 です。
https://www.intel.co.jp/content/www/jp/ja/products/sku/93361/intel-atom-x5z8350-processor-2m-cache-up-to-1-92-ghz/specifications.html
Cherry Trail っていうタブレット向けの SoC らしい。

ストレージはフラッシュメモリ 16GB のモデル。

1G LAN 1口、USB 4口、DisplayPort (HDMI ではない!) 2口。
いろいろつなげそうではあるが、2GB のメモリでどうやりくりするか。

https://www.parkytowers.me.uk/thin/wyse/3040/ によると DisplayPort からの変換器は使えないものもあるらしいですが、うちでは https://www.amazon.co.jp/dp/B08989D7RZ/ が使えました。

開けると M.2 2230 に無線 LAN, Bluetooth の AW-CM389MA が刺さっていました。今回は使いません。
これを外して SSD つけることもできるのかな。でも2230サイズのは入手困難ぽいですね。

使うソフトウェア

OS は Ubuntu 26.04.1 です。

DNS キャッシュサーバは Knot Resolver の6系 にしました。
使ってみたかったので。

Ubuntu インストールメディア用意

https://releases.ubuntu.com/resolute/ から Server install image https://releases.ubuntu.com/resolute/ubuntu-26.04.1-live-server-amd64.iso をダウンロード。
Linux で dd コマンドで USB メモリに書き込む。
USB メモリはマシンに刺しておきます。

BIOS 設定

F2 を押したまま電源投入で BIOS 設定。

https://www.dell.com/support/kbdoc/ja-jp/000128600/dell%E3%82%B7%E3%83%B3-%E3%82%AF%E3%83%A9%E3%82%A4%E3%82%A2%E3%83%B3%E3%83%88%E3%81%AEbios%E3%83%91%E3%82%B9%E3%83%AF%E3%83%BC%E3%83%89%E3%81%A8%E3%81%AF によると BIOS パスワードは「Fireport」と書いてありますが、変更されているのか使用できませんでした。
本体を開けて PWCLR ボタンを押したまま電源を投入したらパスワードなしにできました。

「USB Configuration」で「Enable USB Boot Support」を有効にして Apply し、いったん再起動。

「Boot Sequence」で USB を上位にして Apply し、再起動。

Ubuntu インストール

USB メモリから起動。
「Ubuntu Server (minimized)」を選択。
LVM は使用せず。
最終的にはディスプレイ使わないので「Install OpenSSH Server」を選択。

タイムゾーン設定

# timedatectl set-timezone Asia/Tokyo
# systemctl reboot

パッケージまわり

snapd は使わないので消しておく。

# apt purge -y snapd

パッケージアップデート。

# apt update
# apt upgrade -y
# systemctl reboot

不要となったパッケージを削除。

# apt autopurge -y

必要に応じてコマンド類を入れておく。

# apt install -y vim-tiny less bind9-dnsutils

ログをストレージに残さない

ストレージの消耗を抑えるため、ログはメモリ内に格納するように。
ただし再起動するとログは消えてしまう。

# cd /etc/systemd
# cp -p journald.conf journald.conf.orig
# vi journald.conf
Storage=volatile

# systemctl stop systemd-journald
# rm -rf /var/log/journal/*
# systemctl start systemd-journald

小さい USB メモリを刺してそっちに逃がす形にしてもよさそう。

パッケージの自動アップデート設定

アップデートめんどいので自動にしちゃいます。

再起動まで自動で行うように。

# cd /etc/apt/apt.conf.d
# cp -p 50unattended-upgrades 50unattended-upgrades.orig
# vi 50unattended-upgrades
Unattended-Upgrade::Automatic-Reboot "true";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";

自動アップデートを有効化。

# dpkg-reconfigure unattended-upgrades
Automatically download and install stable updates? [yes/no] yes

うまくアップデートできてるかは後日確認。

Knot Resolver インストール

https://pkg.labs.nic.cz/doc/?project=knot-resolver を参考に。

ca-certificates はすでに入っている。
curl を使うので wget は不要。

# apt install -y apt-transport-https

リポジトリ設定。

# curl -o /usr/share/keyrings/cznic-labs-pkg.gpg https://pkg.labs.nic.cz/gpg
# echo "deb [signed-by=/usr/share/keyrings/cznic-labs-pkg.gpg] https://pkg.labs.nic.cz/knot-resolver resolute main" > /etc/apt/sources.list.d/cznic-labs-knot-resolver.list
# apt update

パッケージインストール。

# apt install -y knot-resolver6

Knot Resolver 設定

いったんサービス停止。

# systemctl stop knot-resolver

キャッシュ領域は tmpfs でメモリを使うように。
ついでに swap ファイルも無効化。

# swapoff -a
# rm /swap.img
# rm /var/cache/knot-resolver/*

# cp -p /etc/fstab /etc/fstab.orig
# vi /etc/fstab

#/swap.img      none    swap    sw      0       0
tmpfs   /var/cache/knot-resolver        tmpfs   rw,size=1G,uid=knot-resolver,gid=knot-resolver,nosuid,nodev,noexec,mode=0700 0 0

# systemctl daemon-reload

# mount /var/cache/knot-resolver

設定ファイル編集。
worker 数はコア数に応じて自動選択。
キャッシュ容量は様子見ながら変更するつもり。

# cd /etc/knot-resolver
# cp -p config.yaml config.yaml.orig

# vi config.yaml
workers: auto
network:
  listen:
    - interface: 0.0.0.0@53
    - interface: ::@53
logging:
  level: info
cache:
  size-max: 700M

53番ポートをつかんでいる systemd-resolved を無効化。

# systemctl stop systemd-resolved
# systemctl disable systemd-resolved

サービス再開。

# systemctl start knot-resolver

コア数ぶん kresd が動いている。

# grep ^processor /proc/cpuinfo
processor       : 0
processor       : 1
processor       : 2
processor       : 3
# ps -ef | grep kresd
knot-re+    2844    2834  1 11:54 ?        00:00:00 /usr/sbin/kresd -c kresd0.conf -n
knot-re+    2845    2834  0 11:54 ?        00:00:00 /usr/sbin/kresd -c kresd1.conf -n
knot-re+    2846    2834  0 11:54 ?        00:00:00 /usr/sbin/kresd -c kresd2.conf -n
knot-re+    2847    2834  0 11:54 ?        00:00:00 /usr/sbin/kresd -c kresd3.conf -n
root        2854    1038  0 11:54 pts/1    00:00:00 grep --color=auto kresd
#

もっとつっこんだ設定をしたいなら下記あたりを参照。

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?