Avatar of Vijay Kumar Gajula
Vijay Kumar Gajula
 asked on

block mails from a particular country in postfix

Is there any possibility to block mails from country wise in Postfix.  for Example I need to block all mails coming from China. Please let me know the process.

Thanks,
Vijay.G
LinuxEmail Servers

Avatar of undefined
Last Comment
Vijay Kumar Gajula

8/22/2022 - Mon
Tim Edwards

Please take a look here, they were able to get this completed with Postfix:

http://freesoftware.zona-m.net/how-to-reject-spam-from-certain-countries-if-you-must-really-really-do-it/
Kent W

The most straightforward way is blocking the /8 IP block of the associated country, via iptables.
The list of IPv4 is here - http://www.iana.org/assignments/ipv4-address-space/ipv4-address-space.xhtml
Ipv6 is here - https://www.iana.org/assignments/bgp-extended-communities/bgp-extended-communities.xhtml#non-trans-ipv6

Regardless of your postfix config, if you block via iptables rules, they won't be able to get mail or any other packets to your server...like bruteforce, etc.
ASKER CERTIFIED SOLUTION
arnold

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Natty Greg

Use PFblocker
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Vijay Kumar Gajula

ASKER
is PFblocker is open source? can we install it in my mail server which is UBUNTU back-end. If So Please let me know the procedure.
Thanks
Natty Greg

Yes PFblocker is open source, however it only installs on PFsense from what I know and found. So maybe use PFsense as your firewall then you'll have all this functionality
Vijay Kumar Gajula

ASKER
Thanks
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.