Commit f1216eb0 authored by Vitaly Lipatov's avatar Vitaly Lipatov

dns: add chat-dns.sh for managing chat.eterfund.ru A records

Round-robin DNS management for MTProto proxy failover: on — set all three A records (91.232.225.3, 95.47.184.52, 217.12.37.55) off — keep only primary IP Uses nsupdate -l (local) for running on ns1. Co-Authored-By: 's avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
parent 6dd31ef2
#!/bin/bash
# chat-dns.sh — manage A records for chat.eterfund.ru
# Run on ns1. Usage: chat-dns.sh on|off|status
#
# on — add all three A records (round-robin)
# off — keep only the primary IP
# status — show current A records
DOMAIN="chat.eterfund.ru"
ZONE="eterfund.ru"
TTL=300
NS="ns1.etersoft.ru"
PRIMARY="91.232.225.3"
EXTRA_IPS="95.47.184.52 217.12.37.55"
usage() {
echo "Usage: $0 on|off|status"
echo " on — set all three A records (round-robin)"
echo " off — keep only primary ($PRIMARY)"
echo " status — show current A records"
exit 1
}
dns_status() {
echo "Current A records for $DOMAIN:"
dig +short "$DOMAIN" A @"$NS"
}
dns_on() {
echo "Adding all A records for $DOMAIN..."
nsupdate -l <<EOF
zone $ZONE
update delete $DOMAIN. A
update add $DOMAIN. $TTL A $PRIMARY
update add $DOMAIN. $TTL A 95.47.184.52
update add $DOMAIN. $TTL A 217.12.37.55
send
EOF
if [ $? -eq 0 ]; then
echo "Done. All three IPs active."
else
echo "nsupdate failed. Check allow-update in zone config." >&2
exit 1
fi
dns_status
}
dns_off() {
echo "Removing extra A records, keeping only $PRIMARY..."
nsupdate -l <<EOF
zone $ZONE
update delete $DOMAIN. A
update add $DOMAIN. $TTL A $PRIMARY
send
EOF
if [ $? -eq 0 ]; then
echo "Done. Only primary IP active."
else
echo "nsupdate failed." >&2
exit 1
fi
dns_status
}
case "${1:-}" in
on) dns_on ;;
off) dns_off ;;
status) dns_status ;;
*) usage ;;
esac
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment