#!/bin/bash
# Check if the script is run as root
if [[ $EUID -ne 0 ]]; then
echo "Bu scripti çalıştırmak için root kullanıcısı olmalısınız." >&2
exit 1
fi
# Update system and install BIND
echo "BIND yükleniyor..."
dnf update -y
dnf install -y bind bind-utils
# Configure firewall for DNS
echo "Firewall ayarları yapılıyor..."
firewall-cmd --add-service=dns --permanent
firewall-cmd --reload
# Configure SELinux
echo "SELinux ayarları kontrol ediliyor..."
setsebool -P named_write_master_zones 1
setsebool -P named_tcp_bind_http_port 1
# Configure named.conf
echo "named.conf dosyası yapılandırılıyor..."
cat > /etc/named.conf <<EOF
options {
listen-on port 53 { 127.0.0.1; 192.168.251.80; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
recursion no;
dnssec-enable yes;
dnssec-validation yes;
bindkeys-file "/etc/named.root.key";
managed-keys-directory "/var/named/dynamic";
session-keyfile "/run/named/session.key";
};
zone "example.lab" IN {
type master;
file "example.lab.db";
};
zone "." IN {
type hint;
file "named.ca";
};
EOF
# Configure zone file for example.lab
echo "DNS zone dosyası oluşturuluyor..."
cat > /var/named/example.lab.db <<EOF
\$TTL 86400
@ IN SOA ns1.example.lab. root.example.lab. (
2023120601 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
)
IN NS ns1.example.lab.
ns1 IN A 192.168.251.80
bmc IN A 192.168.251.80
san IN A 192.168.251.85
san IN A 10.255.255.85
san IN A 172.16.255.85
node1 IN A 192.168.251.81
node2 IN A 192.168.251.82
node3 IN A 192.168.251.83
node4 IN A 192.168.251.84
EOF
# Set proper permissions
echo "Dosya izinleri ayarlanıyor..."
chown root:named /etc/named.conf /var/named/example.lab.db
chmod 640 /etc/named.conf /var/named/example.lab.db
# Enable and start the named service
echo "BIND servisi başlatılıyor..."
systemctl enable named
systemctl start named
# Verify service status
systemctl status named --no-pager
echo "BIND yapılandırması tamamlandı. DNS sunucusu çalışıyor."
6 Aralık 2024 Cuma
Ev atölyesi için alan adı sunucusu ayarlanması
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder