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
반응형

*****************************
POSTFIX 특정 도메인만 SPF check 하기

 

# /etc/postfix/main.cf:

smtpd_recipient_restrictions =
    reject_unlisted_recipient
    ...
    reject_unauth_destination 
    check_sender_access hash:/etc/postfix/sender_access
    ...
smtpd_restriction_classes = spfcheck
spfcheck = check_policy_service unix:private/spfcheck

# /etc/postfix/sender_access:
    aol.com     spfcheck
    hotmail.com spfcheck
    bigfoot.com spfcheck
    ... etcetera ...

 

 

https://serverfault.com/questions/726471/how-to-setup-postfix-to-check-spf-record-only-for-domains-that-i-want-to-check

 

How to setup postfix to check SPF record only for domains that i want to check

I have working postfix server. It configured with amavis and uses pretty good SMTP headers control. But sometimes my users receive spam from spammers with well known mail service providers addresses.

serverfault.com

 

728x90
SMALL
Posted by gromet
728x90
반응형

ribkhan @pixabay

https://pixabay.com/users/ribkhan-380399/

Postfix 5분 지연 발송

 

Postfix를 사용하여 메일 발송 시 5분 지연을 설정하는 방법:

  1. Postfix 설치 확인:
    • Postfix가 이미 설치되어 있는지 확인. RHEL 또는 CentOS에서는 기본적으로 설치.
  2. Postfix 설정 파일 수정:
    • Postfix의 주 설정 파일인 /etc/postfix/main.cf를 편집.
    • 다음 설정을 추가하거나 수정:
      # 메일 발송 지연 설정 (5분 = 300초)
      header_checks = regexp:/etc/postfix/header_checks
      
    • 위 설정은 메일 헤더를 검사하여 지연을 적용.
  3. 지연 설정 파일 생성:
    • /etc/postfix/header_checks 파일을 생성하고 다음 내용을 추가:
      /^Subject:/ HOLD 300
      
    • 이 설정은 메일의 제목이 "Subject:"로 시작할 경우 5분(300초) 동안 지연.
  4. Postfix 재시작:
    • 설정 변경 후 Postfix를 재시작:
      sudo systemctl restart postfix
      
 
 

#postfix #지연발송

 

728x90
SMALL
Posted by gromet
728x90
반응형
아래의 방법은 작동하지 않는다.
POSTFIX가 2개의 헤더를 처리하지 않기 때문이다.

 

POSTFIX 특정 메일 주소에서 온 메일 전달하기

 

어떤 문제로 인해 특정인이 보내는 메일을 다른 메일 주소로 전달해 달라는 요청을 받았다.

처음에는 sender_bcc를 이용해서 전달을 했고 잘 되었다.

하지만 보내는 사람만 확인하고 무조건 전달하는 것이라 수신자가 요청자가 아닐경우에도 동일하게 전달되는 문제가 발생할 수 있었다.

procmail을 사용하고자 하였으나 문서화 된 것이 없었고 어려워 보였다.

 

간단히 할 수 있는 방법을 찾았다.

/To:.*@(?!mail.domain.com) && From:.*@?!extdomain.com/ REDIRECT mailbox@mail.other.domain.com

 

위 예제는 도메인을 기준으로 전달하고 있지만 조금만 수정하면 메일 주소로 적용할 수 있다.

또한 REDIRECT 를 BCC, REJECT 등으로 적용할 수 있다.

 

참고사이트

https://copyprogramming.com/howto/redirect-specific-e-mail-address-sent-to-a-user-to-another-user

 

#postfix #mail #redirect

 

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 2 이전버튼

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

공지사항

Yesterday
Today
Total
반응형

달력

 « |  » 2024.12
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