November 6th, 2013, 10:04 AM
Script to make change to a DNS zone file.
Here's an interesting challenge...
I have a file that contains a list of domain names, one per line.
Files are listed as follows...
I have set of zone files in /var/named
I need to identify all matching files in /var/named that match the domain names in /etc/localdomains and copy them to a new directory /root/temp
Then - for all files in /root/temp I need to replace any instance of mx1.host.net. or mx2.host.net with the domain name corresponding to each file, ending in a period.
e.g. in the filename "mydomain.com.db" look for instances of "mx1.host.net" or "mx2.host.net" and replace with "mydomain.com."
It should do this for all files, using each files own filename before the "db" part, as the replacement for the old mx hostname.
Would this be quite easy?