728x90
반응형

*************************
Postfix 국가도메인(TLD) 차단 방법

 

xxx.ne.jp에서 피싱 / 스팸 메일이 많이 들어와서 국가도메인을 차단하는 방법을 찾아봤다.
아래 2가지 중에 하나만 적용하면 된다.

1. header_checks

/etc/postfix/main.cf

	header_checks = regexp:/etc/postfix/header_checks
    
/etc/postfix/header_checks

	# Some TLD rejections. Kill entire countries.

	/^Received: ..gt .$/ REJECT Sorry, too much spam from Guatemala
	/^Received: ..tw .$/ REJECT Sorry, too much spam from Taiwan
	/^Received: ..kr .$/ REJECT Sorry, too much spam from Korea
	/^Received: ..cr .$/ REJECT Sorry, too much spam from Costa Rica
	/^Received: ..cn .$/ REJECT Sorry, too much spam from China
	/^Received: ..ru .$/ REJECT Sorry, too much spam from RU
	/^Received: ..br .$/ REJECT Sorry, too much spam from Brazil
	/^Received: ..th .$/ REJECT Sorry, too much spam from Thailand
	/^Received: ..tr .$/ REJECT Sorry, too much spam from Turkey

	# Kill known spamming ISPs
	/^Received: ..dynamic.hinet.net .$/ REJECT Sorry, too much spam from HINET

 

2. check_sender_access

/etc/postfix/main.cf

	smtpd_recipient_restrictions = permit_mynetworks,
	permit_sasl_authenticated,
	reject_unauth_pipelining,
	reject_non_fqdn_recipient,
	reject_unauth_destination,
	check_sender_access hash:/etc/postfix/sender_access,
	reject_rbl_client zen.spamhaus.org

/etc/postfix/sender_access

	/.*\.icu$/ REJECT
	/.*\.cn$/ REJECT
728x90
SMALL
Posted by gromet
728x90
반응형

발신자 메일 주소별로 다른 수신자에게 전달는 방법

 

<상황설명>
사용자에게 advertisement@domain.com에서 메일이 들어오고 이 메일 주소의 모든 메일을 검출하여 sysadmin@domain.com으로 전달하고 싶다.

<적용방법>
postfix의 header_checks를 이용하여 redirect 하면 된다.

 

/^From:(.*)advertisement@domain.com/ REDIRECT sysadm@domain.com

 

<참고사이트>
https://wiki.zimbra.com/wiki/How_to_redirect_mails_from_specific_email_to_one_user

 

How to redirect mails from specific email to one user - Zimbra :: Tech Center

How to redirect emails from specific e-mail address to a specific user Resolution In this article we will see how to redirect an email from a specific email address to a designated user. For example you have emails coming from advertisement@domain.com that

wiki.zimbra.com

 

#postfix #header_checks #redirect

728x90
SMALL
Posted by gromet
728x90
반응형

Postfix + header_checks in MySQL

 
In this tip I will describe how to implement Postfix header_checks along with MySQL . No blablabla....let's get straight to the point. For everything to work it is necessary to have MySQL installed. On Debian like distributions, type the following command to install the MySQL server: # apt-get install mysql-server-5.5 After that, follow the installation steps that will be described on the screen. Log in as ROOT in your MySQL and create the database "postfix", or any other name that is easy to identify: # mysql -u root -p CREATE DATABASE postfix; Enter the postfix database to be able to create the table inside it: use postfix;

Now create the header_checks table with the following command:

CREATE TABLE `header_checks` (
  `hc_id` int(11) NOT NULL AUTO_INCREMENT,
  `rule` varchar(255) NOT NULL,
  `action` varchar(255) NOT NULL,
  PRIMARY KEY ( `hc_id`),
  KEY `rule` (`rule`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

Postfix preparation

I believe that you must already have Postfix installed on your server, there are already several articles dealing with its installation.

We will now create the configuration file for communicating with MySQL:

# vi /etc/postfix/header_checks.cf

Put this content inside the file we are editing:
user = YOUR_BANK_USER_postfix
password = YOUR_BANK_PASSWORD_postfix
hosts = IP_or_YOUR_Server_NAME
dbname = DATABASE_NAME_postfix
query = SELECT action FROM header_checks WHERE '%s' REGEXP rule LIMIT 0.1
Next step is to edit the configuration in the /etc/postfix/main.cf file , if you don't already have the line below, add it:
header_checks = mysql:/etc/postfix/header_checks.cf
With these steps completed, we just have to restart postfix and populate the header_checks table in MySQL, which I will show the correct syntax below.

# /etc/init.d/postfix restart

Creating check rules in MySQL

Here we don't have many secrets, what gave me more work was finding the correct syntax to write the rule, but I'll save you this hard work and pass the correct syntax the way I'm using it on my servers.

Access MYSQL:

# mysql -u root -p

use postfix;

INSERT INTO header_checks (`hc_id`, `rule`, `action`) VALUES (NULL, '^From:(.*)domain.com.br', 'DISCARD #SPAM Domain Detected');


Note that the syntax for REGEXP used by header_checks follows the following pattern:

^From:(.*)dominio.com.br

I particularly use this rule to block domains that usually send SPAMs, but we can use it, for example, to block messages with certain subjects, in this case the rule would look like this:

^Subject:(.*)PROPAGANDA

Well folks, that's it...

I hope the subject has been addressed in a clear and objective way.

Hugs.

Measure
Measure
 
 
728x90
SMALL
Posted by gromet
이전버튼 1 이전버튼

블로그 이미지
나는 운이 좋은 사람이다 나는 나날이 점점 더 좋아진다 내가 하는 선택과 행동은 반드시 성공으로 이어진다 내게는 인내력과 지속력이 있다 네게는 좋은것들만 모여든다
gromet

공지사항

Yesterday
Today
Total
반응형

달력

 « |  » 2025.1
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

160x600