Baird, Josh <jba...@follett.com> wrote:

> Any thoughts on a service like Cloudfare's 'CNAME Flattening' [1]?
>
> [1] 
> https://blog.cloudflare.com/introducing-cname-flattening-rfc-compliant-cnames-at-a-domains-root/

Run a command like this from cron

        aname example.com www.example.com | nsupdate -l

Using the aname script below...

Tony.
-- 
f.anthony.n.finch  <d...@dotat.at>  http://dotat.at/  -  I xn--zr8h punycode
Biscay: North or northeast 4 or 5. Slight or moderate. Showers. Good.


#!/usr/bin/perl

use warnings;
use strict;

sub dig {
        my $domain = shift;
        my $type = shift;
        my $ttl;
        my @answer;
        my $qd = quotemeta $domain;
        my $qt = quotemeta $type;
        my @dig = qx{dig +norec $qd IN $qt};
        die "dig $domain IN $type: no reply\n"
            unless @dig;
        while (@dig) {
                if ($dig[0] =~
                        m{^;; ->>HEADER<<- opcode: QUERY, status: (\w+)}) {
                        die "dig $domain IN $type: $1\n"
                            unless $1 eq 'NOERROR';
                        last;
                }
                shift @dig;
        }
        die "dig $domain IN $type: no header\n"
            unless @dig;
        while (@dig) {
                if ($dig[0] =~ m{^;; ANSWER SECTION:}) {
                        last;
                }
                shift @dig;
        }
        die "dig $domain IN $type: no answer\n"
            unless @dig;
        while (@dig) {
                if ($dig[0] =~ m{^\S+\s+(\d+)\s+IN\s+$qt\s+(\S+)}) {
                        $ttl = $1;
                        push @answer, $2;
                }
                if ($dig[0] =~ m{^;; AUTHORITY SECTION:}) {
                        last;
                }
                shift @dig;
        }
        die "dig $domain IN $type: no authority\n"
            unless @dig;
        return ($ttl, @answer);
}

sub nsupdate {
        my $domain = shift;
        my $type = shift;
        my $ttl = shift;
        print "update delete $domain IN $type\n";
        for (@_) {
                print "update add $domain $ttl IN $type $_\n";
        }
}

if (@ARGV != 2) {
        print STDERR "usage: aname <alias> <target>\n"
}

my ($alias,$target) = @ARGV;

my @A = dig $target, 'A';
my @AAAA = dig $target, 'AAAA';

nsupdate $alias, 'A', @A;
nsupdate $alias, 'AAAA', @AAAA;
print "show\nsend\nanswer\n";

exit;

_______________________________________________
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users

Reply via email to