Friday, November 3, 2017

postfix - Mailserver and MX records in Cloudflare




I built my own mail server using postfix/dovecot in CentOS 6, this is my postconf -n results:



alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2

home_mailbox = Maildir/
html_directory = no
inet_interfaces = localhost
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = example.com
myhostname = mail.example.com

mynetworks = 168.100.189.0/28, 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.6.6/README_FILES
relay_domains =
sample_directory = /usr/share/doc/postfix-2.6.6/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
unknown_local_recipient_reject_code = 550



I've tried using telnet to test my emails and I do get them in the /home/user/Maildir/new folder.



I assume everything is OK with the mail server, so I went ahead and added MX records to my DNS settings.



This is the first time I've used Cloudflare's free DNS service, and I admit to not being the most knowledgeable person when it comes to this, but I added a couple of records in there:




  • MX - @ => mail.example.com


  • A - mail.example.com => My VPS ip (where the mail server is located)



The MX record seems to be in place, a quick "dig MX example.com" does wield a result. The problem now is... even though I created the record as mail.example.com, the actual entry as seen via dig is dc-8c1937cd-mail.example.com., a string seems to have been appended to the DNS record.



I've since tried sending email from an outside source (not telnet) without success. Do I need to reconfigure postfix and set myhostname as dc-8c1937cd-mail.example.com.? Am I missing something here in the grander scheme of DNS or is this just the way Cloudflare operates? Could my mailserver not be configured correctly? (logs from my telnet tests look fine)


Answer



Issue was inet_interfaces = localhost, causing postfix only to listen port 25 locally, setting it to inet_interfaces = all fixed the issue.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...