SST Lab Dokuwiki Header header picture

ユーザ用ツール

サイト用ツール


linux:bind_install

文書の過去の版を表示しています。


DNSサーバの構築

最近のトレンドは権威サーバとキャッシュサーバの分離。KVMで2台DNSサーバ立てることにするとそれぞれ単体で設定すればよいので、その方が単純かつセキュア。(まあ、単純なものほどセキュアなものだが)というのはわかっているのだけれど、もうこの歳になると覚えた時のようにやらないとどうもうまくいかない。三子の魂百までなのか雀百まで踊り忘れずなのかはよくわからんが。

研究室の実際の設定はちょっと違うのだけれど、ここでは

ローカルネットワーク
ドメイン名

BINDのインストール

インストールはapt一発。(Ubuntu Serverの場合)

$ sudo apt install bind9

設定ファイル等は/etc/bind以下に収められている。(Ubuntu 22.04.1 LTSで確認)

Setting-up BIND

そんなもん(8.8.8.8)に飛ばしてしまえ!っつうのは無しにして。

基本的には/etc/bind/named.confを変更するのだけれど、bind9.18.1のデフォルトでは

/etc/bind/named.conf
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

のようになっているので、 まずは、/etc/bind/named.conf.optionsに必要な設定をする。

/etc/bind/named.conf.options
acl local-network {
	192.168.10.0/24;
};
options {
	directory "/var/cache/bind";
	allow-query {
		localhost;
		local-network;
	};
	allow-recursion {
		localhost;
		local-network;
	};
	allow-query-cache {
		localhost;
		local-network;
	};
	forwarders {
	 	XXX.XXX.XXX.XXX;
	};
	dnssec-validation auto;
};

forwardersのXXX.XXX.XXX.XXXには学科のDNSサーバを設定する。(将来的に学科のサーバを廃止するときにはどうするんかな)

IPv4プライベートアドレス(RFC1918)のゾーン情報は/etc/bind/named.conf.localに書けって書いてあるのでそれに従い、

/etc/bind/named.conf.local
zone "local" IN {
        type master;
        file "/etc/bind/db.local";
};
zone "10.168.192.in-addr.arpa" IN {
        type master;
        file "/etc/bind/db.10.168.192.in-addr.arpa";
};

のように設定する。

Zoneファイル

/etc/bind/db.local
$ORIGIN local.
$TTL 86400
@         IN  SOA  ns1.local.  mail.address.with.stop.as.delimiter. (
              2022081501  ; serial
              21600       ; refresh after 6 hours
              3600        ; retry after 1 hour
              604800      ; expire after 1 week
              86400 )     ; minimum TTL of 1 day
;
;
          IN  NS     ns1.local.
ns1       IN  A      192.168.10.1
web       IN  A      192.168.10.2
mail      IN  A      192.168.10.3
client    IN  A      192.168.10.4
/etc/bind/db.10.168.192.in-addr.arpa
$ORIGIN 10.168.192.in-addr.arpa.
$TTL 86400
@  IN  SOA  ns1.local.  mail.address.with.stop.as.delimiter. (
       2022081801  ; serial
       21600       ; refresh after 6 hours
       3600        ; retry after 1 hour
       604800      ; expire after 1 week
       86400 )     ; minimum TTL of 1 day
;
@      IN  NS     ns1.local.
;
1      IN  PTR    ns1.local.
2      IN  PTR    web.local.
3      IN  PTR    mail.local.
4      IN  PTR    client.local.

bindの起動

設定ファイルのチェックをした後、bindを起動する。

$ named-checkconf
$ named-checkzone local db.local
zone local/IN: loaded serial 2022081801
OK
$ systemctl start named
$ systemctl status named
$ netstat -aun | grep 53
...
$ dig @localhost www.ee.ous.ac.jp
...

Setting-up BIND as Content Server

Content Serverと書いて権威サーバと読む。

BIND = NSD + Unbound

最近だとこんなのがいいらしい。

  • dnsdist
    • DNSリクエストをバックエンドDNSサーバにフォワード
    • QNAME/リクエスト元IPアドレス/QTYPE等毎にバックエンドDNSサーバを指定
  • NSD
  • Unbound

BINDのインストール

kimi@sstw:~$ qemu-img create -f qcow2 images/content-server.qcow2 80G
Formatting 'images/content-server.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=85899345920 lazy_refcounts=off refcount_bits=16
virt-install \
--name=sstx \
--disk=images/content-server.qcow2,bus=virtio \
--vcpus=2 --ram=2048 \
--graphics vnc,password=*********,listen=0.0.0.0,keymap=ja \
--cdrom iso/ubuntu-22.04-live-server-amd64.iso
 
kimi@sstw:~$ virt-install --name=sstx --disk=images/content-server.qcow2,bus=virtio --vcpus=2 --ram=2048 --graphics vnc,password=********,listen=0.0.0.0,keymap=ja --cdrom iso/ubuntu-22.04-live-server-amd64.iso
WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING  No console to launch for the guest, defaulting to --wait -1
 
Starting install...
Creating domain...                                          |    0 B  00:00     
 
Domain is still running. Installation may be in progress.
Waiting for the installation to complete.
Domain has shutdown. Continuing.
Domain creation completed.
Restarting guest.
kimi@sstw:~$ 
 
kimi@sstb:~$ sudo apt update
Hit:1 http://jp.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://jp.archive.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
All packages are up to date.
kimi@sstb:~$ sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
kimi@sstb:~$ 
kimi@sstb:~$ sudo apt install bind9
 
/etc/bind/named.conf
// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the 
// structure of BIND configuration files in Debian, *BEFORE* you customize 
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local
 
include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";
vi named.conf
cp: cannot create regular file './db.10.168.192.in-addr.arpa': Permission denied
cp: cannot create regular file './db.29.55.150.in-addr.arpa': Permission denied
cp: cannot create regular file './db.31.55.150.in-addr.arpa': Permission denied
cp: cannot create regular file './db.ee.ous.ac.jp': Permission denied
 
 
kimi@sstb:/etc/bind$ systemctl restart named
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'named.service'.
Authenticating as: Kiminori Kakitani (kimi)
Password: 
==== AUTHENTICATION COMPLETE ===
kimi@sstb:/etc/bind$
linux/bind_install.1660803563.txt.gz · 最終更新: 2022/08/23 13:34 (外部編集)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki