Skip to content

Instantly share code, notes, and snippets.

@shivergard
Created November 23, 2013 18:15
Show Gist options
  • Save shivergard/7618077 to your computer and use it in GitHub Desktop.
Save shivergard/7618077 to your computer and use it in GitHub Desktop.
PowerDNS add New Domains FAST
#!/bin/sh
if [ -z "$1" ]
then
echo "No domain defined"
exit
fi
echo ' '>> /etc/powerdns/bindbackend.conf
echo 'zone "'$1'" {' >> /etc/powerdns/bindbackend.conf
echo ' type master;' >> /etc/powerdns/bindbackend.conf
echo ' file "/etc/powerdns/bind/'$1'.zone";' >> /etc/powerdns/bindbackend.conf
echo ' allow-update { none; };' >> /etc/powerdns/bindbackend.conf
echo '};' >> /etc/powerdns/bindbackend.conf
echo "Write IP address EndPoint [ENTER]:"
read ip
echo '$ORIGIN '$1' ; base for unqualified names' > /etc/powerdns/bind/$1.zone
echo '$TTL 1h ; default time-to-live' >> /etc/powerdns/bind/$1.zone
echo '@ IN SOA ns.'$1' hostmaster.'$1' (' >> /etc/powerdns/bind/$1.zone
echo ' 1; serial' >> /etc/powerdns/bind/$1.zone
echo ' 1d; refresh' >> /etc/powerdns/bind/$1.zone
echo ' 2h; retry' >> /etc/powerdns/bind/$1.zone
echo ' 4w; expire' >> /etc/powerdns/bind/$1.zone
echo ' 1h; minimum time-to-live' >> /etc/powerdns/bind/$1.zone
echo ' )' >> /etc/powerdns/bind/$1.zone
echo ' IN NS ns' >> /etc/powerdns/bind/$1.zone
echo ' IN A '$ip >> /etc/powerdns/bind/$1.zone
echo 'ns IN A '$ip >> /etc/powerdns/bind/$1.zone
echo 'webserver IN A '$ip >> /etc/powerdns/bind/$1.zone
echo 'www IN CNAME webserver' >> /etc/powerdns/bind/$1.zone
echo "Test and restart"
service pdns restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment