Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using ipset in conjunction with iptables to create a list of IPs I want to block. I did this:

ipset -N blocking iphash
ipset -A blocking
// and repeated this line for all IPs I want to add to "blocking" list

now I have to add this rule to iptables

if I do this

iptables -A INPUT -m set --set blocking src -j DROP

the IPs will be blocked for everything SSH, FTP, etc. I want just to block them from using my email system dovecot, exim.

how do I do that?

share|improve this question
up vote 2 down vote accepted
iptables -A INPUT -p tcp --dport 25 -m set --set blocking src -j DROP
iptables -A INPUT -p tcp --dport 143 -m set --set blocking src -j DROP

... or whatever ports you're using.

share|improve this answer
simply PERFECT!!!! thanks, you are a genius! – SpaceDog Feb 17 '13 at 23:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.