Plesk for Linux
kb: how-to
ABT: Group A
Applicable to:
- Plesk for Linux
Question
How to add a DNS record to multiple domains via CLI on a Plesk Linux server?
Answer
- Log into the server via SSH.
- Using the command below, create the list of all domains with physical hosting enabled:
# MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -u admin psa -Ne"select name from domains where htype='vrt_hst'" > /root/domains.txt
Note: modify
/root/domains.txt
and exclude the domains that should be left intact. - Run the following command to add DNS record for the domains from the
/root/domains.txt
file:
# cat /root/domains.txt | while read i; do plesk bin dns --add $i -ns ns3 -nameserver example.net;done
Note: in the example above the name server example.net will be added for all domains from the
/root/domains.txt
file.For additional options for adding DNS records via CLI please refer: dns: DNS Zones on Domains .
Comments
5 comments
Hi,
It doesn't works. Nothing happen. No error message.
Hello Miomir Besarabic
Feel free to create a support request about this.
Investigation is required.
Hello
very nice tutotial..
Can you help me? i need to do this but i need to add in bulk this cname :
www.domain.com --> CNAME --> domain.com
The domains.txt is perfect.,
But i can get to work the other part in this case.
YOUR EXAMPLE
mail1.<domain.name> --> CNAME --> webmail.<domain.name>
WITH THIS COMMAND :
# cat /root/domains.txt | while read i; do plesk bin dns --add $i -cname mail1 -canonical webmail.$i ;done
In my case, the canonical parameter is the same domain, in this case $i
so I´ve tried :
# cat /root/domains.txt | while read i; do plesk bin dns --add $i -cname www -canonical $i ;done
and get ERROR
Can anyone help me with this?
Thanks
Fabian
Hi Fabian Marsiglione,
Because for www record, this is added automatically when enabling/disabling www support for the domain:
# plesk bin subscription -u example.com -www true/false
How about UPDATING the SPF record for ALL domains?
Because it's a TXT record, we can't just do a CLI dns -del command AFAIK -- there may be other TXT records..
Please sign in to leave a comment.