Skip to content

Instantly share code, notes, and snippets.

@RobinDaugherty
Last active December 7, 2017 14:50
Show Gist options
  • Save RobinDaugherty/1e22162a076e87e3688e44a70e0239e0 to your computer and use it in GitHub Desktop.
Save RobinDaugherty/1e22162a076e87e3688e44a70e0239e0 to your computer and use it in GitHub Desktop.
Export zone from Dyn Standard DNS
// Since Dyn provides no way to export a zone, this extracts the zone data from the "advanced editor" form.
// Run this in the console on the editor page, and it will produce a single string.
// You may need to clean up the string slightly. Look for hostnames that end with multiple dots and clean those out.
dyn_zone_getter = {
host: jQuery("#adv_table tr > td:nth-child(1)").map(function(){return $(this).text()}),
ttl: jQuery("#adv_table tr > td:nth-child(2) > input").map(function(){return $(this).val()}),
type: jQuery("#adv_table tr > td:nth-child(3)").map(function(){return $(this).text()}),
data: jQuery("#adv_table tr > td:nth-child(4) > input").map(function(){return $(this).val()}),
as_zone: function() {
var z = this;
if(this.host.length == this.ttl.length && this.host.length == this.type.length && this.host.length == this.data.length) {
return Array.prototype.map.call(this.host, function(host, idx) {
return [host, z.ttl[idx], z.type[idx].replace(" ", ""), z.data[idx]].join("\t");
}).join("\n");
} else {
console.error("Failed, sorry.");
}
}
}
dyn_zone_getter.as_zone()
@denvera
Copy link

denvera commented Jan 24, 2017

Thanks, this is super useful. If you have long record names, running
$("acronym").map(function() { $(this).text($(this).attr('title')); return $(this).attr("title"); })
before the above will allow them to not show up abbreviated.

@bjonnh
Copy link

bjonnh commented Jan 26, 2017

Thank you so much!

@chachgithub
Copy link

Can this be done for Dyn Standard DNS? I don't see any editor (with or without a console)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment