Page 1 of 1

Change default SOA

Posted: Sun Feb 09, 2020 6:10 am
by ralbrightii
So on my server, I have vanity nameservers for all domains (ie ns1.domainname.com, ns2.domainname.com), these have corresponding a records for ns1/ns2 to the IP address.

I figured out how to update the default by modifying the default.tpl file in /usr/local/vesta/data/templates/dns folder
Which now reads:
ID='1' RECORD='@' TYPE='NS' PRIORITY='' VALUE='ns1.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='2' RECORD='@' TYPE='NS' PRIORITY='' VALUE='ns2.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='3' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns3%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='4' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns4%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='5' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns5%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='6' RECORD='@' TYPE='NS' PRIORITY='' VALUE='%ns6%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='7' RECORD='ns1' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='8' RECORD='ns2' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='9' RECORD='@' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='10' RECORD='www' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='11' RECORD='ftp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='12' RECORD='mail' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='13' RECORD='smtp' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='14' RECORD='pop' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='15' RECORD='imap' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='16' RECORD='@' TYPE='MX' PRIORITY='10' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='17' RECORD='@' TYPE='TXT' PRIORITY='' VALUE='"v=spf1 a mx ip4:%ip% ~all"' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='18' RECORD='_dmarc' TYPE='TXT' PRIORITY='' VALUE='"v=DMARC1; p=none"' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='19' RECORD='autoconfig' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='20' RECORD='autodiscover' TYPE='A' PRIORITY='' VALUE='%ip%' SUSPENDED='no' TIME='%time%' DATE='%date%'
ID='21' RECORD='_autodiscover' TYPE='SRV' PRIORITY='0 0 443' VALUE='mail.%domain%.' SUSPENDED='no' TIME='%time%' DATE='%date%'


Notice the last 3 records are the autodiscover.xml that I am still working on creating from scratch when the domain is added. (Can set it up manually but, why not have Vesta do it automatically.) <-- another story for another topic though.

My question is, how do I change the default SOA record to match the first ns1 given. For example.com I have the records:
$TTL 14400
@ IN SOA ns1.vestaCPdomain.com. root.example.com. (
2020020803
7200
3600
1209600
180 )

@ 14400 IN NS ns1.example.com.
@ 14400 IN NS ns2.example.com.
ns1 14400 IN A redacted
ns2 14400 IN A redacted
@ 14400 IN A redacted
www 14400 IN A redacted
ftp 14400 IN A redacted
mail 14400 IN A redacted
smtp 14400 IN A redacted
pop 14400 IN A redacted
imap 14400 IN A redacted
@ 14400 IN MX 10 mail.example.com.
@ 14400 IN TXT "v=spf1 a mx ip4:redacted ~all"
_dmarc 14400 IN TXT "v=DMARC1; p=none"
autoconfig 14400 IN A redacted
autodiscover 14400 IN A redacted
_autodiscover 14400 IN SRV 0 0 443 mail.example.com.
_domainkey 14400 IN TXT "t=y; o=~;"
mail._domainkey 14400 IN TXT "v=DKIM1; k=rsa; p=MIGDDAyFanNfPjBAWSpiAfMA0GCSqGSIb3DQEBAQUAA4GNADBM9hYNCBiQKBgQhYo1VOLDEQzUEKJxOVXKnTDOvCzRQ2MqrcCEQW9lNrr19Zm+riOVNRH$ <-- mixed up for security

notice this is a completely freshly made domain in VestaCP. I just would like the SOA to be ns1.example.com vs ns1.vestacpdomain.com

Is there a way to update that?

Re: Change default SOA

Posted: Sun Feb 09, 2020 7:14 am
by ralbrightii
So piggy backing....

I got the change to happen and not happen. I changed some lines in #Update domain zone to the following:

# Update domain zone
update_domain_zone() {
domain_param=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
eval $domain_param
SOA=$(idn --quiet -a -t "$SOA")
if [ -z "$SERIAL" ]; then
SERIAL=$(date +'%Y%m%d01')
fi
if [[ "$domain" = *[![:ascii:]]* ]]; then
domain_idn=$(idn -t --quiet -a $domain)
else
domain_idn=$domain
fi
zn_conf="$HOMEDIR/$user/conf/dns/$domain.db"
echo "\$TTL $TTL
@ IN SOA ns1.$domain. root.$domain. (
$SERIAL
7200
3600
1209600
3600 )
" > $zn_conf
fields='$RECORD\t$TTL\tIN\t$TYPE\t$PRIORITY\t$VALUE'
while read line ; do
IFS=$'\n'
for key in $(echo $line|sed "s/' /'\n/g"); do
eval ${key%%=*}="${key#*=}"
done

RECORD=$(idn --quiet -a -t "$RECORD")
if [ "$TYPE" = 'CNAME' ] || [ "$TYPE" = 'MX' ]; then
VALUE=$(idn --quiet -a -t "$VALUE")
fi

if [ "$SUSPENDED" != 'yes' ]; then
eval echo -e "\"$fields\""|sed "s/%quote%/'/g" >> $zn_conf
fi
done < $USER_DATA/dns/$domain.conf
}

The italicized parts are the changes:
1) the first change was change $SOA. to ns1.$domain.
2) the second change was change root.$domain_idn to ns1.$domain.
3) the third change was change the 180 to 3600 <-- this is the Minimum TTL, which DNSInspect.com was always complaining about.

So I make these changes and then DNSInspect.com shows everything correctly, however, VestaCP shows the SOA as the still old field of ns1.VestaCPdomain
Now to figure out how to update that one.... if anyone has any ideas, I am all ears.