Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Dev Section Modification & Patches
  • Search

DNS stop working after 99 DNS record change per day

Section with modification and patches for Vesta
Post Reply
  • Print view
Advanced search
4 posts • Page 1 of 1
pggj
Posts: 2
Joined: Tue Oct 22, 2019 5:44 pm

Os: Ubuntu 17x
Web: apache + nginx
DNS stop working after 99 DNS record change per day
  • Quote

Post by pggj » Tue Oct 22, 2019 6:50 pm

(sory for bad english, not my first language, and a long day at work !)
Hello,
I leave this post because i found a 'bug'. I pose here the problem, the analysis, and the resolution. If a VestaCP developer could incorporate the modification in the source code, it would be useful for many of us!

The problem:
During massive transfer of some of my servers, I have a script that modify DNS configuration record by record on the fly. After a while, the DNS server was falling down, and I had to completely remove the DNS from the domain to recreate it.

Origin of the bug :
After analysis, I concluded that it is the 'serial' attached to the DNS record that was involved. Serial format is YYYMMDDXX where XX is a number incremented each time the DNS configuration is changed. In conclusion, you can not make more than 99 DNS change in one day on a domain.

Solution:
In order to overcome this, I made the following changes:

in file /usr/local/vesta/func/domain.sh :
in function update_domain_zone()

Replace :

Code: Select all

    if [ -z "$SERIAL" ]; then
        SERIAL=$(date +'%Y%m%d01')
    fi
By :

Code: Select all

    if [ -z "$SERIAL" ]; then
        SERIAL=$(date +'%y%m%d0001')
    fi
and replace function update_domain_serial() by this one :

Code: Select all

update_domain_serial() {
    zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
    if [ -e $zn_conf ]; then
        zn_serial=$(head $zn_conf |grep 'SOA' -A1 |tail -n 1 |sed "s/ //g")
        s_date=$(echo ${zn_serial:0:6})
        c_date=$(date +'%y%m%d')
        if [ "$s_date" == "$c_date" ]; then
            cur_value=$(echo ${zn_serial:6} )
            new_value=$(expr $cur_value + 1 )
            len_value=$(expr length $new_value)
            if [ 1 -eq "$len_value" ]; then
                new_value='000'$new_value
            fi
            if [ 2 -eq "$len_value" ]; then
                new_value='00'$new_value
            fi
            if [ 3 -eq "$len_value" ]; then
                new_value='0'$new_value
            fi
            serial="$c_date""$new_value"
        else
            serial="$(date +'%y%m%d0001')"
        fi
    else
        serial="$(date +'%y%m%d0001')"
    fi
    add_object_key "dns" 'DOMAIN' "$domain" 'SERIAL' 'RECORDS'
    update_object_value 'dns' 'DOMAIN' "$domain" '$SERIAL' "$serial"
}

You will be abe to make up to 9999 DNS change per day and per domain

Hoping it will help !

----------------------
Having issues with your server ? contact me !

Pierre-Guillaume - MathsiMo
Last edited by pggj on Tue Sep 08, 2020 7:57 pm, edited 1 time in total.
Top

jkarlos
Posts: 1
Joined: Thu Apr 30, 2020 4:47 am

Os: Ubuntu 17x
Web: apache + nginx
Re: DNS stop working after 99 DNS record change per day
  • Quote

Post by jkarlos » Thu Apr 30, 2020 4:51 am

Hello!, please change this error:

Code: Select all

if [ 1 -eq "$len_value" ]; then
	new_value=000'$new_value
for:

Code: Select all

if [ 1 -eq "$len_value" ]; then
	new_value='000'$new_value
Thank you!, I really appreciate your work.
Top

pggj
Posts: 2
Joined: Tue Oct 22, 2019 5:44 pm

Os: Ubuntu 17x
Web: apache + nginx
Re: DNS stop working after 99 DNS record change per day
  • Quote

Post by pggj » Tue Sep 08, 2020 7:59 pm

Thank you for this corection, I directly modified the post :)
Top

skamasle
Collaborator
Posts: 592
Joined: Mon Feb 29, 2016 6:36 pm

Re: DNS stop working after 99 DNS record change per day
  • Quote

Post by skamasle » Mon Oct 12, 2020 10:01 am

Nice work, not much people make 99 changes in one domain per day but its ok

I recomend you make a pull request in github or open same issue in github
Top


Post Reply
  • Print view

4 posts • Page 1 of 1

Return to “Modification & Patches”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password