LoginSignup
0
0

More than 3 years have passed since last update.

DNS構築 with CentOS7

Last updated at Posted at 2019-12-15

この記事の範囲

・vmを立ててunboundを使って名前解決できるようになるまで

VM環境構築

$ vagrant box add centos7 https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box
$ vagrant init centos7
$ vim Vagrantfile //vagrantfileを編集してprivateネットワークを設定しておく
$ vagrant up
$ vagrant ssh

DNSサーバ構築

$ export LC_ALL=C //これをやっておかないと変なエラーが出る
$ yum update
$ yum install -y vim
$ yum install -y unbound
$ yum install -y bind-utils ←digコマンドのため

unbound.conf設定

/usr/sbinと/etc/unbound/にフォルダーが追加される
$ cd /etc/unbound
$ vim unbound.conf //unbound基本設定
$ vim /etc/unbound/conf.d/unbound.conf //このファイルに社内ドメインゾーン情報を書き込んでいく

unbound.conf設定内容

------------------------------
server:
       interface: 0.0.0.0     ←すべてのアドレスからの問い合わせに回答(IPv4)
       interface: ::0       ←すべてのアドレスからの問い合わせに回答(IPv6)       

       access-control: 0.0.0.0/0 refuse   ←デフォルト拒否(IPv4)
       access-control: 127.0.0.0/8 allow  ←ループバックアドレスを許可(IPv4)

       logfile: "/var/log/unbound.log"
       use-syslog: no

       local-zone: "mtc." static ←mtc.が付いてるが設定にないドメインが来た時 ex hoge.mtc
       local-data: "test.mtc. IN A 192.0.2.51"

       forward-zone:           ←アンコメントする
       name: "."            ←すべてのドメインに対してフォワード
       forward-addr: 8.8.8.8      ←フォワード先DNS(今回はGoogle Public DNS)
       forward-addr: 8.8.4.4
------------------------------

一旦以下のコマンドで間違いがないかチェックする

$ unbound-checkconf

次にこのコマンドで起動してみる

$ sudo service unbound start

設定ファイルをいじったら再起動を忘れずに!

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