We help IT Professionals succeed at work.
Get Started

Extracting data from zone files

MAVERICK
MAVERICK asked
on
769 Views
Last Modified: 2010-04-21
I'm looking for a solution to the following problem...
I need a 3 column file of the domains like this
mydomain1.tld 10.0.0.85 ns1.mywebserver.tld.
mydomain2.tld 10.0.0.85 ns1.mywebserver.tld.
mydomain3.tld 10.0.0.86 ns1.myotherserver.tld.

I'm  in  the named zone root directory & grep returns a list of zone files like this..
#grep -lr 'SOA' *
zones5/12/experts-exchange.com
zones4/11/mydomain1.tld
zones4/15/mydomain2.tld

I can get the data into individual lists but not combined...
eg the domain names using..
# grep -r 'SOA' *|grep 'zones'|cut -d ':' -f 1|cut -d '/' -f 3
the dns server..
# cat `grep -r 'SOA' *|grep 'zones'|cut -d ':' -f 1`|grep '*'|awk '{print $5}
the IP of the website
cat `grep -r 'SOA' *|grep 'zones'|cut -d ':' -f 1`|grep 'SOA'|awk '{print $4}'

Here is a sample zone file
# cat /hsphere/local/var/named/zones16/5/maverick.tld
;BIND DUMP V8
$ORIGIN tld.
maverick   86400   IN      NS      ns2.myserver.tld.    ;Cl=3
        86400   IN      NS      ns1.myserver.tld.    ;Cl=3
        86400   IN      SOA     ns2.myserver.tld. nocadmin.myserver.tld. (
                2003123101 10800 3600 604800 86400 )    ;Cl=3
        86400   IN      A       10.0.0.84  ;Cl=3
        86400   IN      MX      10 pop3.maverick.tld.        ;Cl=3
$ORIGIN maverick.tld.
mail    86400   IN      CNAME  10  maverick.tld.   ;Cl=3
*       86400   IN      A       10.0.0.84  ;Cl=3

Thanks everyone
MAVERICK
Comment
Watch Question
This problem has been solved!
Unlock 2 Answers and 14 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE