Applicable to:
- Plesk for Linux
- Plesk for Windows
How to update an SPF record for all domains that already have a particular record?
Answer
Note: it is necessary to delete existing SPF DNS records before creating new ones via CLI.
PLESK_WARN: It may take considerable time to apply the changes even for a single domain.
-
Connect to the server via RDP;
-
Create a list of domains that contain a specific SPF record, e.g. "specific_record":
C:\> plesk db -Ne "SELECT d.name FROM domains AS d, dns_zone AS z, dns_recs AS r WHERE d.name=z.name AND z.id=r.dns_zone_id AND r.type='txt' AND r.val LIKE '%spf%' AND val LIKE '%specific_record%';" > domains.txt
- Create a list of existing SPF records for the domains:
C:\> plesk db -Ne "SELECT r.val FROM domains AS d, dns_zone AS z, dns_recs AS r WHERE d.name=z.name AND z.id=r.dns_zone_id AND r.type='txt' AND r.val LIKE '%spf%' AND val LIKE '%specific_record%';" > spf.txt
- Delete existing SPF records for domains from the list:
C:\> for /f %i in (domains.txt) do (for /F "tokens=*" %j in (spf.txt) do ("%plesk_cli%\dns.exe" -d %i -txt "%j"))
If the following record occurs, safely ignore it:
CONFIG_TEXT: Unable to del record in DNS server: unable to find DNS record
- Create new SPF records for domains in the list:
C:\> for /f %i in (domains.txt) do ("%plesk_cli%\dns.exe" -a %i -txt "v=spf1 some_spf_text local")
-
Connect to the server via SSH;
-
Create a list of domains:
# plesk bin domain --list > domains.txt
- Remove all specific SPF records (e.g. "specific record") from ALL domains:
# for i in $(cat domains.txt); do plesk bin dns -d $i -txt "specific record"; done
- Add the new SPF record (e.g. "new SPF record") as follows:
# for i in $(cat domains.txt); do plesk bin dns -a $i -txt "new SPF record"; done
Comments
0 comments
Please sign in to leave a comment.