1. Cài đặt dịch vụ BIND
Mount đĩa CDROM:
mount /dev/sr0 /mnt
cd /mnt/Packages
yum -y install bind-chroot
systemctl status named
rpm -qc bind
2. Cấu trúc cấu hình BIND
- Tệp chính: /etc/named.conf (thiết lập tổng thể)
- Tệp vùng: /etc/named.rfc1912.zones (định nghĩa vùng DNS)
- Thư mục dữ liệu: /var/named (chứa bản ghi DNS)
3. Cấu hình phân giải thuận/nghịch
3.1. Cấu hình phân giải thuận
// Sửa /etc/named.conf
options {
listen-on port 53 { 127.0.0.1; };
allow-query { any; };
};
3.2. Cấu hình vùng phân giải
// Thêm vào /etc/named.rfc1912.zones
zone "example.com" IN {
type master;
file "example.com.zone";
};
zone "100.168.192.in-addr.arpa" IN {
type master;
file "example.com.rev";
};
3.3. Tạo tệp dữ liệu
cd /var/named
cp -p named.localhost example.com.zone
cp -p named.loopback example.com.rev
chown root:named *.zone
3.4. Kiểm tra cấu hình
named-checkconf
named-checkzone example.com example.com.zone
4. Thiết lập Master-Slave DNS
4.1. Cấu hình Master
// Thêm vào cấu hình vùng:
zone "example.com" IN {
type master;
file "example.com.zone";
allow-transfer { 192.168.1.20; };
};
4.2. Cấu hình Slave
// Cấu hình vùng trên Slave:
zone "example.com" IN {
type slave;
masters { 192.168.1.10; };
file "slaves/example.com.zone";
};
5. Phân giải tách biệt (Split DNS)
5.1. Mô hình mạng
| Thiết bị | IP | Giao diện |
| DNS Server | 192.168.1.10/10.0.0.10 | ens3/ens4 |
| Client LAN | 192.168.1.100 | ens3 |
| Client WAN | 10.0.0.200 | ens4 |
5.2. Cấu hình phân giải phân tách
// Sửa /etc/named.conf
view "internal" {
match-clients { 192.168.1.0/24; };
zone "example.com" {
type master;
file "example.com.local";
};
};
view "external" {
match-clients { any; };
zone "example.com" {
type master;
file "example.com.public";
};
};
5.3. Tạo tệp dữ liệu khác biệt
// example.com.local
$TTL 1D
@ IN SOA ns1.example.com. admin.example.com. (
2023082001 ; Serial
)
IN A 192.168.1.10
www IN A 192.168.1.50
// example.com.public
$TTL 1D
@ IN SOA ns1.example.com. admin.example.com. (
2023082001 ; Serial
)
IN A 10.0.0.10
www IN A 10.0.0.50