Score:0

ubuntu iptables configuration for connceting to SMTP relay

cn flag

An application on a server (Ubuntu also installed with postfix) can send out mails via SMTP.
A seperate application on the server could send out mails via SMTP, but with a different user@FQDN.
No incoming mail is meant to be managed on the server.
The SMTP service would receive mails to relay via port 465 in one instance, and port 587 in another (gmail).

What should the server's iptables configuration be?

  • only output for port 465, 587 and 25?
  • only output for port 25?
  • input and output for all 465, 587 and 25?

My understanding is that only output for port 25 is required (the application will specify HELO domain and port)

sudo iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT

I was provided a suggestion as follows, however sport does not appear in the basic options listed here, thus I am uncertain how to parse these two options.

sudo iptables -A OUTPUT -p tcp --sport 25 -m conntrack --ctstate ESTABLISHED -j ACCEPT

What is the best course of action? and how can I test that the port is open for outgoing traffic vs incoming traffic?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.