
Monitoring DKIM records, SPF and DMARC from Centreon
Well, Well, Well… We're back with Centreon! Today a post to keep track of public records related to the email service. So if we don't want to have mail problems, we will make sure that the DKIM record, SPF and DMARC exist in our domain.
If we want to have a perfectly configured email service, we know that we have to have the DKIM records perfectly configured, SPF and DMARC, for this we have multiple pages that will help us create them, validate them and ensure that we meet the standards, We get a good reputation and we won't be penalized by the anti-spam systems of other organizations. As said, the mythical website of https://www.mail-tester.com It will help us in having the optimal configuration.
Once this work is done, From the monitoring team we can simply confirm that these records exist and are not lost, since there are so many things that we have to consider in an organization, What better than someone to look at every critical point of the organization.
DKIM
Total, txapas apart, In this post we are going to get that through a couple of scripts we can integrate them into Centreon to know that the records are valid, We start with 'check_dkim', We install the requirements and download the script:
Yum Install Python36-Devel PiP3.6 Install PyCrypto PiP3.6 Install DNSpython cd /usr/lib/centreon/plugins/ git clone https://github.com/countsudoku/check_dkim.git cd check_dkim/
And we test the operation directly from shell, each one obviously with its name in the public domain:
/usr/bin/python3.6 /usr/lib/centreon/plugins/check_dkim/check_dkim.py -d bujarra.com -s default DKIM OK - DKIM key is there
SPF
The same, We install requirements, We download the script 'check_spf_record_match.rb', We make it executable:
Yum install Ruby -y wget HTTPS://raw.githubusercontent.com/garymoon/nagios-check-spf-record-match/master/check_spf_record_match.rb chmod +x check_spf_record_match.rb
And we tried it:
/usr/lib/centreon/plugins/check_spf_record_match.rb --domains bujarra.com --debug Options: {:debug=>True, :domains=>["bujarra.com"]} record for bujarra.com: v=spf1 include:_spf.srv.cat +a +mx include:pepipost.net ~all OK: All records in sync.
DMARC
Para usar este script nos basamos en el script anterior de SPF, creamos el de DMARC haciendo una copia del fichero actual y vamos a crear uno para nosotros.
cp ./check_spf_record_match.rb ./check_dmarc_record_match.rb
Y le hacemos los siguientes cambios:
- Sustituimos la palabra spf por dmarc
- Sustituimos la palabra SPF por DMARC
- On the line 50
- of: records = dns.getresources(domain, Resolv::DNS::Resource::IN::TXT)
- a: records = dns.getresources(‘_dmarc.’ + domain, Resolv::DNS::Resource::IN::TXT)
- On the line 65
- of: dmarc_record_n = txt_strings.index{|s| s.downcase.include?’DMARC’}
- a: dmarc_record_n = txt_strings.index{|s| s.include? ‘DMARC’}
- On the line 70
- of: puts txt_strings.index{|s| s.downcase.include?’DMARC’}
- a: puts txt_strings.index{|s| s.include?’DMARC’}
/usr/lib/centreon/plugins/check_dmarc_record_match.rb --domains bujarra.com --debug Options: {:debug=>True, :domains=>["bujarra.com"]} record for bujarra.com: v=DMARC1; p=none OK: All records in sync.