The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Howto: Sync nameservers!

Discussion in 'Bind / DNS / Nameserver Issues' started by amdmachine, Jan 27, 2004.

  1. amdmachine

    amdmachine Member

    Joined:
    Feb 20, 2003
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    If you're like us and utilize two dedicated machines as your nameservers running WHM/Cpanel you will notice that zone files do not sync to well. I’ve found that in some cases newly added sub domain entries on one of our servers takes anywhere up to 2 days to appear in the backup zone files on our secondary nameserver.

    1. Create the file /root/sync.sh on your secondary nameserver.

    Paste the following code into the file:
    Code:
    # Bash Script to Sync Name Servers
    
    echo "Changing Directory";
    cd /var/named
    echo "Directory changed to /var/named";
    echo "Now removing all zone files";
    rm -rf *.db
    echo "Zone files removed";
    echo "Now time to get up-to-date zone files from master name server";
    cd /scripts
    ./dnstransfer
    echo "Now we wait 15seconds before syncing";
    sleep 15s
    echo "Now let's update named!";
    /sbin/service named restart
    sleep 10s
    echo "Done!";
    2. Now chmod this file to 777 'chmod 777 /root/sync.sh'.
    3. Now edit the crontab file and add the entry to automatically run this script every 4hours 'vi /var/spool/cron/root'

    Add '0 */4 * * * /bin/bash /root/sync.sh' to end of root's crontab file.

    4. Run this command to install the newly added conrtab entry 'crontab /var/spool/cron/root'

    Working perfect for us!

    Note: Add 'MAILTO=domain@name.ext' to the crontab file if you want the output emailed to you.
     
  2. kris1351

    kris1351 Well-Known Member

    Joined:
    Apr 18, 2003
    Messages:
    963
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Lewisville, Tx
    Awesome setup there adm! This would be useful to add to your secondaries to help get rid of the secondary server problems with Cpanel adding and removing add-on domains. Thanks a bunch.
     
  3. H2Hosting.com

    H2Hosting.com Well-Known Member

    Joined:
    Sep 4, 2001
    Messages:
    192
    Likes Received:
    0
    Trophy Points:
    16
    amdmachine, 'chmod 777 /root/sync.sh' is BAD idea ;)
     
  4. kris1351

    kris1351 Well-Known Member

    Joined:
    Apr 18, 2003
    Messages:
    963
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Lewisville, Tx
    Runs fine with 755. Could probably just put it down to 500 and it would run fine.
     
  5. amdmachine

    amdmachine Member

    Joined:
    Feb 20, 2003
    Messages:
    17
    Likes Received:
    0
    Trophy Points:
    1
    Good point, 'chmod 544 /root/sync.sh' is probably a safer idea.

    In my situation 777 is just a safe, the server is highly secure beyond convention cPanel setup and it's sole purpose is just to act as the secondary dns server. Everything else is locked out, with no accounts to be installed on it.
     
Loading...

Share This Page