linux.newbie

Well-Known Member
Sep 8, 2006
73
0
156
Accidently synced all zones from the nameservers to a shared server. Is there a way to clean up the zones not hosted locally on the shared server ?
Tried cleandns but I think it will remove the zone entry only if the db file is not present.
 

PlatinumServerM

Well-Known Member
PartnerNOC
Jul 10, 2005
400
3
168
New Jersey, USA
cPanel Access Level
Root Administrator

sneader

Well-Known Member
Aug 21, 2003
1,179
57
178
La Crosse, WI
cPanel Access Level
Root Administrator
I opened a ticket regarding a similar issue, and asked about a script. cPanel was able to clean things up for me, and the tech said he'd post a script and the process in the near future, in case others could benefit from this.

- Scott
 
Last edited:

Spiral

BANNED
Jun 24, 2005
2,020
8
193
I have several specialized scripts to do these sort of tasks but to be perfectly honest, you would be much better off rebuilding your DNS zones from scratch unless you have a lot of custom edits you are trying to protect.

I'd just wipe (or preferably move) the /var/name/*.db files from their current
location and then renamed your /etc/named.conf file and then you can issue a rebuild of the "named" server config file and DNS zones and that should get you back up and running again in about 15 seconds.
 

mahinder

Well-Known Member
Jun 12, 2003
69
0
156
matrix
does anyone have this script, which compare /var/named/domain.com.db zone in /etc/localdomains and then remove it / move it to another folder ?
 

Spiral

BANNED
Jun 24, 2005
2,020
8
193
does anyone have this script, which compare /var/named/domain.com.db zone in /etc/localdomains and then remove it / move it to another folder ?
If your intent is cleaning up you DNS, you are going about it the wrong way!

However, since you asked:
Code:
#!/bin/bash
IFS="$"

# Put the folder you want to move the zones to below:
TARGET="/var/localzones"

cd /var/named

if [ ! -d ${TARGET} ]; then
   mkdir ${TARGET}
fi

### If you want to move out remotedomains, change next line:

cat /etc/localdomains | while read CPDOMAIN; do 
   if [ -f /var/named/${CPDOMAIN}.db ]; then
      mv /var/named/${CPDOMAIN}.db ${TARGET}/${CPDOMAIN}.db
   fi
done
 

mahinder

Well-Known Member
Jun 12, 2003
69
0
156
matrix
If your intent is cleaning up you DNS, you are going about it the wrong way!
thank you for script. Can you please tell me what would be the correct way?.

We have 6 servers in cluster and number of zones have increased to 7000+, all are setup to sync with each other and now its taking long time for bind/named to load all zones at startup. named.conf has increased to 50,000 lines.

I have changed settings on all web servers to syn only with dns server and dns server do not sync zones with web servers. Now, We want to remove unnecessary zones from web servers but want to keep all zones only on dns server where they are backed up every few hours.

Can you please suggest any workaround for it?
 

Spiral

BANNED
Jun 24, 2005
2,020
8
193
I could probably tell you better if I saw your current DNS configuration.

I do have scripts that can sort out zones back to their original servers but sounds like your DNS might not be setup the best it could be setup.