46 lines
1.2 KiB
Bash
46 lines
1.2 KiB
Bash
#!/bin/bash
|
|
# نصب BIND9 و فعالسازی zone modstagram.com روی سرور Asiatech
|
|
# اجرا: bash install-bind9.sh
|
|
|
|
set -e
|
|
|
|
ZONE_FILE="/etc/bind/db.modstagram.com"
|
|
SOURCE="$(dirname "$0")/modstagram.com.zone"
|
|
|
|
apt-get update
|
|
apt-get install -y bind9 bind9utils
|
|
|
|
cp "$SOURCE" "$ZONE_FILE"
|
|
chown root:bind "$ZONE_FILE"
|
|
chmod 644 "$ZONE_FILE"
|
|
|
|
if ! grep -q 'zone "modstagram.com"' /etc/bind/named.conf.local 2>/dev/null; then
|
|
cat >> /etc/bind/named.conf.local << 'EOF'
|
|
|
|
zone "modstagram.com" {
|
|
type master;
|
|
file "/etc/bind/db.modstagram.com";
|
|
};
|
|
EOF
|
|
fi
|
|
|
|
# اجازه query از بیرون
|
|
OPTIONS_FILE="/etc/bind/named.conf.options"
|
|
if grep -q 'allow-query' "$OPTIONS_FILE"; then
|
|
sed -i 's/allow-query { any; };/allow-query { any; };/' "$OPTIONS_FILE" || true
|
|
else
|
|
sed -i '/recursion yes;/a \ allow-query { any; };' "$OPTIONS_FILE" || true
|
|
fi
|
|
|
|
named-checkconf
|
|
named-checkzone modstagram.com "$ZONE_FILE"
|
|
|
|
systemctl enable bind9
|
|
systemctl restart bind9
|
|
|
|
echo ""
|
|
echo "BIND9 OK. تست محلی:"
|
|
dig @127.0.0.1 api.modstagram.com +short
|
|
echo ""
|
|
echo "قدم بعد: در پنل رجیسترار NS را به ns1.modstagram.com و ns2.modstagram.com تغییر دهید + Glue records"
|