Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richard-scott/61aba48af8661c2996a7a164d1655a70 to your computer and use it in GitHub Desktop.
Save richard-scott/61aba48af8661c2996a7a164d1655a70 to your computer and use it in GitHub Desktop.
Script to extract the DNS entries from 123-reg advanced dns page

Extract DNS entries from 123-reg advanced DNS page

123-reg do not support exporting their zone files, which prompted me to create a script to extract the DNS entries automatically.

Instructions

Read through the script to confirm for yourself that it does nothing malicious. All it does is to get the info from the page and log it to your console.

  1. Login to your 123-reg control panel.
  2. Manage the domain you want to get entries from.
  3. Go to "Manage DNS (A, MX, CNAME, TXT, SRV)".
  4. Click on the "Advanced DNS" tab.
  5. Open the Developer tools in your browser (common shortcuts include F12 or Ctrl+Shift+I).
  6. Click on the "Console" tab in developer tools.
  7. Copy and paste the above script.
  8. The output to the console should be in zone file format.

Disclaimer

I am not affiliated with 123-reg. Their advanced DNS page may change at any time, which may break this script.

License

Public Domain

var table = document.getElementsByClassName('advanced_dns')[0];
var rows = table.getElementsByTagName('tr');
var i, len, row;
var hostname, type, priority, ttl, destination;
var output = '';
output += '$TTL 600\n'; // start with default TTL
// skip header and last two rows (add new entry, delete all entries)
for (i = 1, len = rows.length - 2; i < len; i++) {
row = rows[i];
hostname = row.getElementsByClassName('dns_hostname')[0].innerText;
type = row.getElementsByClassName('dns_type')[0].innerText;
priority = row.getElementsByClassName('dns_priority')[0].innerText;
ttl = row.getElementsByClassName('dns_ttl')[0].innerText;
destination = row.getElementsByClassName('dns_data')[0].title;
if (type === 'TXT/SPF') {
if (destination.match(/^(v=spf1|spf2.0)/) !== null) {
type = 'SPF';
} else {
type = 'TXT';
}
destination = '"' + destination + '"';
}
output += [hostname, ttl, 'IN', type, priority, destination].join(' ') + '\n';
}
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment