Re: How to get the CNAME for a domain?

2017-01-10 Thread Mark Andrews

Use named-checkconf to get the list of master and slave zones from
named.conf then transfer them all and extract the CNAME ownername
that matches.

named-checkconf -p |
awk '$1 == "zone" { zone = $2; next; }
$1 == "type" && ( $2 == "slave;" || $2 == "master;" ) { print zone }' |
sed -e 's/^"//' -e 's/"$//' |
dig axfr -f - |
awk -v VSERVER=${VSERVER} '$4 == "CNAME" && $5 == VSERVER { print $1 }'

-- 
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742 INTERNET: ma...@isc.org
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


Re: How to get the CNAME for a domain?

2017-01-10 Thread Tony Finch
Michelle Konzack  wrote:
>
> OK, I can grep the whole /etc/bind/master/ directory, but since my  Name
> Server is responsable for several 1000 (sub)domains,  the  execution  of
> the script takes ages!

Your approach seems reasonable to me. I'm surprised it takes that long,
unless "several" is 10s or 100s of thousands!

You can make your script tighter, though I would be surprised if it
improves the performance much.

find /etc/bind/master -type f |
egrep -v '(.conf|.signed|.private|.key)$' |
xargs egrep -h "IN CNAME.*${VSERVER}" |
sed 's|\.[ \t]*IN CNAME.*||'

Tony.
-- 
f.anthony.n.finch    http://dotat.at/  -  I xn--zr8h punycode
Forth, Tyne, Dogger, Fisher: West or southwest 5 to 7, increasing gale 8 or
perhaps severe gale 9 later. Moderate or rough, occasionally very rough later.
Rain or showers. Good, occasionally poor.
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users


How to get the CNAME for a domain?

2017-01-10 Thread Michelle Konzack
Hello experts,

I do not want to querry the world, but only my own Name Server for CNAME
configured (or not).

Currently I am updating my web administration interface and I have  lost
over the time a script, which queried my Name Server for CNAMES.

E.g. if I have a physical server  I  like  to
know, which CNAMEs (on MY Name Server) pointing to it as

www.electronica.tamay-dogan.netIN CNAMEvserver04.tamay-dogan.net

OK, I can grep the whole /etc/bind/master/ directory, but since my  Name
Server is responsable for several 1000 (sub)domains,  the  execution  of
the script takes ages!

[tdgetincname]--
#!/bin/bash

VSERVER="$1"

LIST=`cd /etc/bind/master/ && find -type f |grep -v -E 
"(.conf|.signed|.private|.key)$" |sed 's|^\./||' |sort`

for FILE in ${LIST}
do
  RET=`cd /etc/bind/master/ && grep -E "IN CNAME.*${VSERVER}" ${FILE} |sed 
"s|\.[ \t]*IN CNAME.*||"`

  if [ -n "${RET}" ]
  then
echo "${RET}"
  fi
done


Note: If I do not the "cd /etc/bind/master/ &&",
  I exceed the maximum lenght of the commandline.

Any ideas how to do this better?

Thanks in avance

-- 
Michelle KonzackITSystems
GNU/Linux Developer 0033-6-61925193


signature.asc
Description: Digital signature
___
Please visit https://lists.isc.org/mailman/listinfo/bind-users to unsubscribe 
from this list

bind-users mailing list
bind-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/bind-users