Displaying certain nameservers for domains

LawsHosting

Verified User
Joined
Sep 13, 2008
Messages
2,426
Location
London UK
I would like to display/save all nameservers for domains, here is what I currently have:
Code:
for u in `ls /usr/local/directadmin/data/users`; do
{
   for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
   {
     echo "------------$d------------"
     nslookup -querytype=NS $d >> /tmp/domain_list.txt
     echo "--------------------------"
     done;
   }
   done;
}
However, I would like for it to just display if the nameservers are different to, say, ns1.laws-hosting.co.uk, n2., n3, n4, in this format:.
------------domain------------
domain nameserver = nameserver
...
....
--------------------------
I understand the cut command will be used here, I'm not too hot on bash scripting.

Any advice will be grateful.

EDIT:

I forgot to say my nameservers are hosted elsewhere. :o
 
Last edited:
Ok mine should be a stupid idea and not complete for sure...

But, for have all domains NS should be enough do:

Code:
cat /var/named/* | grep NS

Then you should take output and send it to file and edit it.

Am i wrong?

Regards
 
googling just a bit i found this for remove duplicates:

uniq remove duplicate lines (normally from a sorted file)

example: sort infile1 | uniq -c > outfile2

-c show count of lines
-d only show duplicate lines

Should be helpful?
 
Code:
#!/bin/sh

for u in `ls /usr/local/directadmin/data/users`; do
    for d in `cat /usr/local/directadmin/data/users/$u/domains.list`; do
        if [ ! -z "`dig +short @8.8.4.4 $d ns | grep -iv 'laws-hosting.co.uk'`" ]; then
            echo "----------$d--------------"
            dig +short @8.8.4.4 $d ns
            echo "--------------------------"
            echo
        fi
    done
done
 
Great script, scsi. For those of you who can't get it to work, you may be using a text editor which doesn't like the ` (backquote) character; you may have to edit the file manually, or change to an editor which works.

Now, scsi, can we talk you into doing a script which will compare the server ns records against the ns records listed at the root serves, and tell us the difference (in other words print out information only for the domains where the nameservers don't match? I just don't have the time for that right now.

If you do, and if you can, thanks.

Jeff
 
Great script - well done scsi! :)

When I ran the script, I noticed that it does not do a lookup for the domains that are setup as pointers/aliases within DirectAdmin.

Just letting you know...
 
Back
Top