The Best Price for IPv4/IPv6 Lease – Any RIR & Any Geo-LocationOrder Now
Hostperl

Setup Postfix DMARC Policy on Ubuntu VPS: Complete Email Authentication

By Raman Kumar

Share:

Updated on Jun 15, 2026

Setup Postfix DMARC Policy on Ubuntu VPS: Complete Email Authentication

Understanding DMARC Email Authentication

DMARC (Domain-based Message Authentication, Reporting & Conformance) works with SPF and DKIM to protect your domain from email spoofing. When you setup Postfix DMARC policy on Ubuntu VPS, you create email authentication that helps legitimate messages reach inboxes while blocking fraudulent ones.

Your email server needs proper DMARC configuration to maintain good sender reputation. Gmail and Outlook increasingly rely on DMARC policies to determine whether emails land in inboxes or spam folders.

Prerequisites and System Requirements

Before configuring DMARC, verify your Ubuntu VPS has these components ready:

  • Postfix mail server installed and operational
  • SPF record configured in DNS
  • DKIM authentication working properly
  • DNS management access for your domain
  • Root or sudo access to the server

Check your current Postfix status:

sudo systemctl status postfix
sudo postconf -n | grep mydomain

If you need to configure SPF authentication first, our SPF authentication setup guide provides the foundation for DMARC implementation.

Installing DMARC Analysis Tools

Install OpenDMARC to process DMARC policies on your mail server:

sudo apt update
sudo apt install opendmarc

The OpenDMARC package provides policy enforcement and reporting capabilities.

Create the main configuration file:

sudo nano /etc/opendmarc.conf

Add the basic configuration:

AuthservID HOSTNAME
PidFile /var/run/opendmarc/opendmarc.pid
RejectFailures false
TrustedAuthservIDs HOSTNAME
Socket inet:8893@localhost
UMask 0002
UserID opendmarc:opendmarc
IgnoreAuthenticatedClients true
RequiredHeaders true

Replace HOSTNAME with your actual server hostname. The socket configuration allows Postfix to communicate with the DMARC service.

Creating DNS DMARC Records

DMARC policies are published through DNS TXT records. Start with a monitoring-only policy to observe email behavior without blocking messages.

Create a TXT record for _dmarc.yourdomain.com with this content:

v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com; ruf=mailto:dmarc@yourdomain.com; fo=1

The policy parameters mean:

  • v=DMARC1 - DMARC version identifier
  • p=none - Take no action on policy failures (monitoring mode)
  • rua - Aggregate report destination email
  • ruf - Forensic report destination email
  • fo=1 - Generate reports on any authentication failure

Verify the DNS record propagation:

dig TXT _dmarc.yourdomain.com

For Hostperl VPS hosting customers, DNS changes typically propagate within 15 minutes across our network.

Configuring Postfix DMARC Integration

Edit the Postfix main configuration to integrate DMARC checking:

sudo nano /etc/postfix/main.cf

Add the DMARC milter to your configuration:

smtpd_milters = inet:localhost:8891, inet:localhost:8893
non_smtpd_milters = inet:localhost:8891, inet:localhost:8893
milter_protocol = 6
milter_default_action = accept

Port 8893 connects to OpenDMARC, while 8891 typically handles DKIM. The milter_default_action accepts messages when milters are unavailable, preventing mail delivery disruption.

Test the configuration syntax:

sudo postfix check

No output indicates successful validation. Reload Postfix to apply changes:

sudo systemctl reload postfix

Starting and Managing DMARC Services

Enable and start the OpenDMARC service:

sudo systemctl enable opendmarc
sudo systemctl start opendmarc

Verify the service is running and listening:

sudo systemctl status opendmarc
sudo netstat -tlnp | grep 8893

Check the service logs for any startup issues:

sudo journalctl -u opendmarc -f

The logs should show successful socket binding and no error messages. If you see permission errors, verify the opendmarc user has proper access to required directories.

Running email services on your VPS requires reliable infrastructure and ongoing maintenance. Hostperl managed VPS hosting includes email server optimization and 24/7 monitoring to ensure your DMARC policies work consistently.

Testing DMARC Policy Implementation

Send test emails to verify DMARC processing works correctly. Use mail command from your server:

echo "DMARC test message" | mail -s "Testing DMARC" test@gmail.com

Check the message headers in the received email for DMARC authentication results:

Authentication-Results: mx.google.com;
       dmarc=pass (p=none dis=none) header.from=yourdomain.com

A "dmarc=pass" result indicates successful policy validation.

Monitor the mail logs for DMARC processing:

sudo tail -f /var/log/mail.log | grep -i dmarc

Look for log entries showing DMARC policy lookups and evaluation results.

Monitoring DMARC Reports and Performance

DMARC generates two types of reports: aggregate (RUA) and forensic (RUF). Aggregate reports arrive daily and contain statistical information about email authentication.

Set up a dedicated email address to receive reports:

sudo useradd -m dmarc-reports
sudo nano /etc/aliases

Add the alias:

dmarc: dmarc-reports

Update the alias database:

sudo newaliases

Reports contain XML data showing authentication results from major email providers. Parse these reports to identify delivery issues or unauthorized email sources using your domain.

Our email deliverability checklist covers comprehensive monitoring strategies for VPS email servers.

Implementing Stricter DMARC Policies

After monitoring email patterns for several weeks, gradually implement stricter policies. Change from monitoring to quarantine mode:

v=DMARC1; p=quarantine; rua=mailto:dmarc@yourdomain.com; ruf=mailto:dmarc@yourdomain.com; fo=1; pct=25

The pct=25 parameter applies the policy to 25% of messages, allowing gradual implementation. Monitor report feedback to ensure legitimate emails aren't affected.

Eventually move to reject policy for maximum protection:

v=DMARC1; p=reject; rua=mailto:dmarc@yourdomain.com; ruf=mailto:dmarc@yourdomain.com; fo=1

The reject policy blocks all messages failing DMARC authentication. Only implement this after confirming all legitimate email sources pass validation.

Troubleshooting Common DMARC Issues

DMARC failures often stem from alignment issues between different authentication methods. Check SPF and DKIM configuration if reports show authentication problems:

sudo opendmarc-testkey -d yourdomain.com -s default
dig TXT yourdomain.com | grep spf

Subdomain policies require specific configuration. Add subdomain policy if needed:

v=DMARC1; p=quarantine; sp=reject; rua=mailto:dmarc@yourdomain.com

The sp parameter sets policy for subdomains separately from the main domain.

If milter communication fails, check firewall rules and port availability:

sudo ufw status
sudo ss -tlnp | grep 8893

Restart services in the correct order when troubleshooting:

sudo systemctl restart opendmarc
sudo systemctl restart postfix

Frequently Asked Questions

How long should I monitor before implementing strict DMARC policies?

Monitor for at least 2-4 weeks to establish email patterns. Large organizations may need longer observation periods to identify all legitimate email sources and third-party services.

Can DMARC block legitimate emails from my domain?

Yes, if SPF or DKIM authentication fails for legitimate sources. Start with p=none monitoring policy and gradually implement restrictions after verifying all authorized email sources pass authentication.

What happens if my VPS goes down during DMARC processing?

Email providers cache DMARC policies for up to 24 hours. Your policy remains active even during server downtime, but new policy updates won't propagate until DNS is accessible again.

Do I need separate DMARC policies for different subdomains?

Not necessarily. The main domain policy applies to subdomains by default. Use the sp parameter only if subdomains need different handling than your primary domain policy.

How do I handle DMARC reports from multiple domains on one server?

Configure separate report addresses for each domain or use a centralized reporting service. Parse reports programmatically if managing multiple domains to avoid manual processing overhead.