Postfix mail server limit the mailbox size

Posted on in Categories Linux, Postfix, Tips, Troubleshooting, Tuning, UNIX last updated October 19, 2007

So how do you limit the mailbox size for users configured with the Postfix mail server?

It is good choice to avoid problem (disk DoS) by limiting mailbox size. This will avoid the user or hacker to eat up all hard disk space.

Display the default mailbox size limit

Type the following command:
# postconf mailbox_size_limit

mailbox_size_limit = 51200000

51200000 bytes is default mailbox size limit.

Display the default maximum size in bytes of a message

Type the following command:
# postconf message_size_limit

message_size_limit = 10240000

Setup new mailbozsize limit

Open file /etc/postfix/ and
# vi /etc/postfix/
Add/modify/set values as follows:
mailbox_size_limit = 30000000
message_size_limit = 10240000

Save and restart postfix mail server:
# /etc/init.d/postfix restart

Linux Iptables: How to block or open mail server / SMTP protocol

Posted on in Categories CentOS, Debian Linux, Iptables, Linux, Networking, RedHat/Fedora Linux, Security last updated November 12, 2007

SMTP is used to send mail. Sendmail, Qmail, Postfix, Exim etc all are used on Linux as mail server. Mail server uses the TCP port 25. Following two iptable rule allows incoming SMTP request on port 25 for server IP address (open port 25):
iptables -A INPUT -p tcp -s 0/0 –sport 1024:65535 -d –dport 25 -m state –state NEW,ESTABLISHED -j ACCEPT

iptables -A OUTPUT -p tcp -s –sport 25 -d 0/0 –dport 1024:65535 -m state –state ESTABLISHED -j ACCEPT

In order to block port 25 simply use target REJECT instead of ACCEPT in above rules.

And following two iptables rules allows outgoing SMTP server request for server IP address
iptables -A OUTPUT -p tcp -s –sport 1024:65535 -d 0/0 –dport 25 -m state –state NEW,ESTABLISHED -j ACCEPT

iptables -A INPUT -p tcp -s 0/0 –sport 25 -d –dport 1024:65535 -m state –state ESTABLISHED -j ACCEPT