- Linux Training
- Desktop Tutorials
- Server Tutorials
|Protect Postfix From Attack|
|Server Training - Mail Server|
Protection From Attack
Postfix has a setting that will protect the system from attack. An attack could either be a client system that is mis configured or it could be a malicious attack that was attempting to issue commands to compromise the server. Either way, system resources are wasted unless another option is available. In fact, Postfix has three settings that will begin a process of increasing delays in responding to these types of attacks.
smtpd_error_sleep_time = 2s
smtpd_soft_error_limit = 10
The first line is the sleep or delay time. After the system senses 10 attacks from the same source the 11th attack is delayed 12 seconds, the 12th attack is delayed 14 seconds, etc. Once it reaches the hard limit the misbehaving client is disconnected. In the example, the soft limit is 10 and the hard limit is 20. These settings can all be changed to reflect your needs.
This practice will help you set up the soft and hard limits for attack parameters. Edit your main.cf file and place the following settings in it, at the end of the file. Configure your hard limit at 25, your soft limit at 15 and use a 1 second delay. Once this is complete, contact your instructor so it may be reviewed on your practice server.
8 Week Course for $499.95 ORDER NOW
Filtering Header and Body Content
Postfix provides an option to create Spam filters for incoming mail using regular expressions. This mail is filtered before it is accepted by the mail server so it will not use mail server resources as much. These two lines must be entered into the main.cf file in order for filters to work. You do not need to use both filter types you may choose only to filter headers or the body.
header_checks = regexp:/etc/postfix/header_checks
body_checks = regexp:/etc/postfix/body_checks
Note that both of these filters refer to a file that is located in the /etc/postfix directory. These files will need to be created. These files will then contain the regular expressions that will be used as filter rules.
Reducing Spam and Attack by Limiting IP Addresses
SysAdmin (Nov. 2005, Vol.14,Num 11, p.16 “Geo-Ip Blocking with IP Tables: Some Common Sense Firewall Rules”)
The basis behind the thought here is that these IP Address Ranges probably do not need access to your network in any way, unless you are an International business. By blocking these country ranges you may be reducing SPAM and Malware by up to 25%. In addition, in the event of a catastrophic virus outbreak you may create a window of time to secure your server by blocking these IP Ranges. The following website keeps track of network subnets that are related to each country.
Brazil and Argentina
Implementing these restrictions will require you to add statements to your iptables in order to specifically drop subnets. From the command line you will need to add a line to indicate the subnet source that you want to drop on the INPUT table. Here is an example that drops the subnet at 126.96.36.199/8.
iptables -A INPUT -s 188.8.131.52/8 -j DROP
As an alternative you may want to only limit access to countries via port 80. This line will drop all attempts from the subnet at 184.108.40.206/8 in reaching any port except port 80.
iptables -A INPUT -s 220.127.116.11/8 -p tcp -dport ! 80 -j DROP