1

I have Postfix running on an Ubuntu 16.04 server for Gitlab and I am able to send email out to most domains except my corporate domain. From what I can tell, Postfix never tries the mail server IP address under my domain. For this example, say my email is skrawn@company.com and the mail server is at 11.101.1.40. The Postfix mail log reports:

Jan  5 10:05:10 linux-dev postfix/smtp[2058]: connect to company.com[11.202.17.1]:25: Connection timed out
Jan  5 10:05:40 linux-dev postfix/smtp[2058]: connect to company.com[11.101.1.46]:25: Connection timed out
Jan  5 10:06:10 linux-dev postfix/smtp[2058]: connect to company.com[11.101.56.8]:25: Connection timed out

So it's not even trying the actual mail server at 11.101.1.40. I search around and saw suggestions of editing the /etc/hosts file to manually map the domain to the correct IP. So in my hosts file, I added:

11.101.1.40    company.com

Then to make Postfix use the hosts file as well as the DNS servers, I add this to /etc/postfix/main.cf:

smtp_host_lookup=dns, native

Reloaded postfix, restarted the server, etc. Postfix is still not trying the mail server IP.

So, I changed the /etc/postfix/main.cf to

smtp_host_lookup=native

And it works!

Jan  5 10:22:27 linux-dev postfix/smtp[1317]: 9DBC61A405FB: to=<skrawn@company.com>, relay=company.com[11.101.1.40]:25, delay=90665, delays=90664/0.04/0.51/0.26, dsn=2.0.0, status=sent (250 Message accepted for delivery)

Ok, so maybe I just need to change the smtp_host_lookup so it checks native first:

smtp_host_lookup=native, dns

No luck. It sill won't try 11.101.1.40. Any ideas on what I am missing the configuration? I'd like to be able to send emails both to that mail server and to other domains. Thank you for any help!

| improve this question | | | | |
  • 2
    Usually this is done with MX records, not random hosts entries. – thrig Jan 5 '17 at 17:40
  • 1
    Agreed with @thrig; what do you see if you run dig mx yourcompany.com or host yourcompany.com? – DopeGhoti Jan 5 '17 at 17:42
  • $ dig mx company.com ; <<>> DiG 9.10.3-P4-Ubuntu <<>> mx company.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11315 ;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4000 ;; QUESTION SECTION: ;company.com. IN MX ;; AUTHORITY SECTION: company.com. 699 IN SOA company.com. admin. 24380 900 600 86400 3600 ;; Query time: 0 msec ;; SERVER: 10.85.0.2#53(10.85.0.2) ;; WHEN: Thu Jan 05 10:43:01 MST 2017 ;; MSG SIZE rcvd: 96 – skrawn Jan 5 '17 at 17:46
  • $ host company.com company.com has address 11.101.56.8 company.com has address 11.101.1.46 company.com has address 11.202.17.1 – skrawn Jan 5 '17 at 17:47
0

Most of postfix trouble in communicating that I run in, I did fix with these settings.

inet_protocols=ipv4
inet_interfaces = all
myhostname = mail.dom.com
smtpd_banner = $myhostname
mydomain = dom.com
myorigin = $mydomain
mydestination = localhost
mynetworks = 127.0.0.0/8

Also in /etc/hosts

127.0.0.1       localhost
127.0.0.1       mail.dom.com alias
192.168.1.100   mail.dom.com  alias
99.222.33.44    mail.dom.com  alias  # YOUR ISP assigned IP

Also be sure that you select inet_interfaces = all so postfix can listen on all of your domains that you set in the /etc/hosts

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.