#!/bin/bash # #/var/tmp/named_dump.db #kill -SIGINT `ps axf | grep named | grep -v grep | awk '{print $1}'` #Suck data out of PTR records too? NAMECACHE="/tmp/morehosts" DEBUG="YES" isdigits () { #up to 10 digits. 1998012502 case $1 in [0-9]|[0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]|[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]) return 0 ;; #True [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]) return 0 ;; #True *) return 1 ;; #False esac } CURRORIGIN="" CURROBJ="" unset F1 F2 F3 F4 F5 F6 F7 read F1 F2 F3 F4 F5 F6 F7 while [ -n "${F1}" ]; do case "${F1}" in "\$ORIGIN") #Change origin # CURRORIGIN=`echo ${F2} | sed -e 's/\.$//'` CURRORIGIN=${F2%.} #FIXME - should we clear CURROBJ here? ;; ";"|";;") #Comment, ignore #FIXME - lines that start w/ semicolon immediately followed by some other char. ;; *) #Real DNS record case "${F3} ${F4}" in "IN A") if isdigits ${F2} ; then echo -e "${F5}\t${F1}.${CURRORIGIN}" >>${NAMECACHE} CURROBJ=${F1} if [ "${DEBUG}" = "YES" ]; then echo -e "${CURROBJ}\t${CURRORIGIN}"; fi else echo -e "unrecognized: ${F1}\t${F2}\t${F3}\t${F4}" fi ;; "IN CNAME") #FIXME - suck A records out, if possible, and insert if isdigits ${F2} ; then CURROBJ=${F1} if [ "${DEBUG}" = "YES" ]; then echo -e "${CURROBJ}\t${CURRORIGIN}"; fi else echo -e "unrecognized: ${F1}\t${F2}\t${F3}\t${F4}" fi ;; "IN AAAA"|"IN HINFO"|"IN MX"|"IN NS"|"IN PTR"|"IN RP"|"IN SOA"|"IN TXT"|"IN WKS") if isdigits ${F2} ; then CURROBJ=${F1} if [ "${DEBUG}" = "YES" ]; then echo -e "${CURROBJ}\t${CURRORIGIN}"; fi else echo -e "unrecognized: ${F1}\t${F2}\t${F3}\t${F4}" fi ;; *) case "${F2} ${F3}" in "IN A") if isdigits ${F1} ; then echo -e "${F4}\t${CURROBJ}.${CURRORIGIN}" >>${NAMECACHE} else echo -e "${F4}\t${F1}.${CURRORIGIN}" >>${NAMECACHE} CURROBJ=${F1} if [ "${DEBUG}" = "YES" ]; then echo -e "${CURROBJ}\t${CURRORIGIN}"; fi fi ;; "IN CNAME") #FIXME - suck A records out, if possible, and insert if isdigits ${F1} ; then echo "NADA" >/dev/null else CURROBJ=${F1} if [ "${DEBUG}" = "YES" ]; then echo -e "${CURROBJ}\t${CURRORIGIN}"; fi fi ;; "IN AAAA"|"IN HINFO"|"IN MX"|"IN NS"|"IN PTR"|"IN RP"|"IN SOA"|"IN TXT"|"IN WKS") if ! isdigits ${F1} ; then CURROBJ=${F1} if [ "${DEBUG}" = "YES" ]; then echo -e "${CURROBJ}\t${CURRORIGIN}"; fi fi ;; *) case "${F1} ${F2}" in "IN A") echo -e "${F3}\t${CURROBJ}.${CURRORIGIN}" >>${NAMECACHE} ;; "IN CNAME") #FIXME - suck A records out, if possible, and insert ;; "IN AAAA"|"IN HINFO"|"IN MX"|"IN NS"|"IN PTR"|"IN RP"|"IN SOA"|"IN TXT"|"IN WKS") ;; *) if isdigits ${F1} && isdigits ${F2} && isdigits ${F3} && isdigits ${F4} ; then if [ "${F6}" = ")" -o "${F7}" = ")" ]; then echo "NADA" >/dev/null #echo -e "\t\t\t\tnumbers" else echo -e unrecognized line: echo -e "${F1}\t${F2}\t${F3}\t${F4}\t${F5}\t${F6}\t${F7}" fi else echo -e "unrecognized: ${F1}\t${F2}\t${F3}\t${F4}" fi ;; esac ;; esac ;; esac ;; esac unset F1 F2 F3 F4 F5 F6 F7 read F1 F2 F3 F4 F5 F6 F7 done