Wildcards in Whitelist/blacklist

Questions and answers about how to do stuff
Post Reply
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Wildcards in Whitelist/blacklist

Post by rpw »

What wildcards are supported in the Whitelist/Blacklist on MailWatch? I've tried the "*" but it doesn't seem to work.

Thanks Richard.
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

Appears I've found my answer over on the mail scanner faq. Apparently you can't use wildcards at all. Looks like my blacklist is going to get VERY LARGE.
User avatar
shawniverson
Posts: 3783
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: Wildcards in Whitelist/blacklist

Post by shawniverson »

Hmm....feature request? Or you can perhaps use a postfix rule instead since it allows regex and wildcards?
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

I'd be interested in any solution. As I've mention I'm not very good with Linux (yet) so I'd need a bit of schooling on how to.
User avatar
shawniverson
Posts: 3783
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: Wildcards in Whitelist/blacklist

Post by shawniverson »

It takes some tweaking in postfix, here's the post I saw that describes how to do it.

http://permalink.gmane.org/gmane.mail.v ... nner/80423

I'll highlight the important parts...

In /etc/postfix/main.cf...

smtpd_client_restrictions = reject_unknown_client_hostname,
check_sender_access pcre:/etc/postfix/sender_access
smtpd_sender_restrictions = reject_unknown_sender_domain,
check_sender_access pcre:/etc/postfix/sender_access

In /etc/postfix/sender_access

Code: Select all

/\.example$/                 REJECT
'
Reject anything from example TLD
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

Thanks, I'll post back results.
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

OK. The information you've provided. Is this added to the existing main.cf or does it replace the two lines in the file?
Also sender_access is blank. Am I adding the /\.example$/ REJECT ? Or what? What I want to reject at this time is China (.cn), Russia (.ru), Palau (.pw) and .asia. How would I format that into the sender access?

Thanks.
Richard
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

Went ahead and "added" the lines after the other smtpd lines and added /\.pw REJECT plus the others in the sender access file. Hope this is correct.

As a follow on is there a way to report number of rejected emails? By domain?

Thanks.
Richard.
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

FYI; .asia didn't get blocked. Do I need to restart anything?
rpw
Posts: 29
Joined: 18 Jul 2014 22:22

Re: Wildcards in Whitelist/blacklist

Post by rpw »

Follow up, after configuring it blocked ALL email coming in so I know I did something wrong.
User avatar
shawniverson
Posts: 3783
Joined: 13 Jan 2014 23:30
Location: Indianapolis, Indiana USA
Contact:

Re: Wildcards in Whitelist/blacklist

Post by shawniverson »

Feel free to share your postfix edits...
irow
Posts: 20
Joined: 30 Sep 2015 01:53

Re: Wildcards in Whitelist/blacklist

Post by irow »

I followed the instructions in Shawn's link above, to block the .top TLD, and it worked without any problems. The sender_access file already exists. I just copied and pasted the additional four lines to the end of the /etc/postfix/main.cf file:

Code: Select all

smtpd_client_restrictions = reject_unknown_client_hostname,
check_sender_access pcre:/etc/postfix/sender_access
smtpd_sender_restrictions = reject_unknown_sender_domain,
check_sender_access pcre:/etc/postfix/sender_access
and populated the sender_access file (which was blank) with

Code: Select all

/\.top$/                 REJECT
I then restarted postfix, and no more .top messages. :whistle:
Post Reply