以前都在
紅帽圈設定與架設DNS server,今天筆記一下如何在Ubuntu Server安裝與架設一個master DNS server。
Step1. 安裝DNS server
$ sudo apt install bind9
Step2. 新增Zone
$ cd /etc/bind9
$ sudo vi zones.example.com
zone "example.com" {
type master;
file "/etc/bind/db.example.com";
};
Step3. 將新增的Zone加入到DNS server
$ sudo vi named.conf.local
include "/etc/bind/zones.example.com";
Step4. 建立zone file
$ sudo vi db.example.com
$TTL 86400
@ IN SOA server1.example.com. root.server1.example.com. (
1 ; Serial
86400 ; Refresh
3600 ; Retry
2419200 ; Expire
84600 ) ; Negative Cache TTL
IN A 10.10.10.253
IN NS server1.example.com.
server1 IN A 10.10.10.253
x1 IN A 10.10.10.100
Step5. 重新啟動DNS server
$ sudo systemctl restart bind9
以下開始來測試囉!
Step1. 將DNS指向localhost
$ sudo vi /etc/netplan/50-cloud-init.yaml
network:
ethernets:
enp0s3:
dhcp4: true
nameservers:
addresses: [127.0.0.1, 168.95.1.1]
version: 2
$ sudo netplan apply
Step2. 來個正解查詢:
$ host server1.example.com
server1.example.com has address 10.10.10.253