Solved

What port does sendmail send mail on?

Posted on 2009-07-08
8
1,351 Views
Last Modified: 2013-12-18
Hi,

I would like to completely firewall my linux box's internet interface. I want to block all incoming packets and accept only outgoing packets from sendmail, as this is the only service that should need internet access. Does sendmail use port 25 for outgoing packets? Do I need any other ports open?

Also, when setting an iptables rule for OUTPUT packets, do I refer to the source port instead of the destination port?

Thanks
0
Comment
Question by:tomp_gl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 11

Assisted Solution

by:dekkar
dekkar earned 50 total points
ID: 24809722
Should be port 25, but it can be changed. If you dont have any other functions that need to access the net on that server, then 25 is the only port you need open.
0
 
LVL 57

Accepted Solution

by:
giltjr earned 200 total points
ID: 24809759
SMTP uses a destination port of 25 and a source port that is 1024 or greater.

For OUTPUT you use the destination port.

Typically for IP protocols the source port is a random port that is 1024 or greater.  You typically filter/block based on destination port.

0
 

Author Comment

by:tomp_gl
ID: 24809815
The server will only be sending mail, not accepting it. Would I need to accept INPUT packets to established or related connections? Also, do I need to accept ping requests?

Essentially I want to do this:

# only let sendmail out
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
iptables -P OUTPUT DROP
# let nothing in
iptables -P INPUT DROP

But will I need to keep any other source ports open for OUTPUT packets?

Thanks
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 250 total points
ID: 24809820
HI,

SMTP uses Port 25 by default. So does sendmail.

If you want to block incoming e-mail traffic then don't include any rules that allow port 25 among your iptables rules.

But when sendmail wants to send mail to oustside the default

iptables -A input -m state --state ESTABLISHED,RELATED -j ACCEPT

rule will allow your SMTP server to connect to outside SMTP servers over the default SMTP port.
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 250 total points
ID: 24809826
If all you want is this then you don't need any other ports. But you might like servers to access your DNS if it is located at the same segment though.

0
 

Author Comment

by:tomp_gl
ID: 24809834
If sendmail is using a random source port then I should probably accept all OUTPUT packets... are there any security ramifications to this?
0
 
LVL 30

Assisted Solution

by:Kerem ERSOY
Kerem ERSOY earned 250 total points
ID: 24809880
You've already accomplsh this.

to say --dport=25 means --sport 0:65535 also. so you don't need another port.
0
 
LVL 57

Assisted Solution

by:giltjr
giltjr earned 200 total points
ID: 24809931
Typically you allow anything out.  If you want to allow only specific packets out, then you want to allow based on destination port, not source port.

So:

# let sendmail out
iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
# let DNS queries out, both TCP and UDP
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -P OUTPUT DROP

Then use the entry that KeremE had in his post

# allow inbound TCP traffic if we established the connection outbound
iptables -A input -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT DROP

However, this means that NOTHING other than smtp and DNS queries gets OUT.  You can't surf the web, you can't ftp, you have NO way to get patches/updates from the network.

Again, typically any traffic is allowed out and only inbound traffic is filters.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
managed Distribution list in postfix 2 23
Windows ADHow to restrict port 6881 bit Torrent 3 44
Checkpoint interface differences 1 50
PowerMTA - Competing product 6 56
Workplace bullying has increased with the use of email and social media. Retain evidence of this with email archiving to protect your employees.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In this video we show how to create a mailbox database in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Servers >> Data…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question