Script to update DKIM entries in a BIND zone file
2021-08-11 | ||
test | ||
README.md | ||
update-dkim.py |
Script to update DKIM entry in BIND zone file
This script takes two arguments:
- a BIND DNS zone file
- a DNS record generated by 'opendkim-genkey'
opendkim-genkey
is part of the opendkim-tools
Debian package
This script use regex to
- extract the DKIM selector and the value of the TXT record from the DKIM TXT record generated by opendkim-genkey
- replace the DKIM selector and TXT value in the zone file with the new values
Example
- generate a new DKIM key for mail.example.org
- remember to increase the increment if generating a new key on the same date
INCREMENT=1; /usr/sbin/opendkim-genkey -b 2048 -d mail -s $(/bin/date +%Y%m%d)-$INCREMENT
# generate a DNS DKIM TXT record such as '20210811-1.txt'
/usr/sbin/opendkim-genkey -b 2048 -d example.org -s $(/bin/date +%Y%m%d)-1
Then run this update-dkim.py, passing the zone file you want to update and the above .txt file:
update-dkim.py <zone file> 20210811-1.txt