I would highly appreciate it if someone could help on a quite simple ipset rule I am trying to set up. I cannot really understand why it does not seem to work. So here it goes:
I create a simple file with IP addresses I would like to block and call it blocklist.
Then I create my ipset and reference it like this:
ipset create blocklist nethash for i in $(cat /path/to/blocklist); do ipset add blocklist $i; done -A INPUT -p tcp --match multiport --dport 25,587 -m set --match-set blocklist src -j DROP
When I verify it with
ipset test blocklist (IP address here) and press enter
it says the IP address is on the list.
When I verify it with
iptables -L -n -v
it says my iptables' rule is there and in action.
However, when I connect from the IP address that is on the blocklist it does not block this IP address by saying connection timed out, it simply gets connected and goes right through... I am lost... Could anybody advise, please where is there a mistake in my setting? Any pointers / assistance / suggestions, etc. are most welcome! Many thanks in advance!
P.S. It works OK when I set it without any multiport options and blocks only one port like this:
-A INPUT -p tcp --dport 80 -m set --match-set blocklist src -j DROP
but when I do the same thing but on the 25th port it won't work:
-A INPUT -p tcp --dport 25 -m set --match-set blocklist src -j DROP
I cannot really figure it out. I have Postfix running OK and listening onto my 25th port.
P.S.S. The only thing that comes to my mind is that there is a limit of ipset's sets that I can have (is that possible at all?) that's why my last rule does not work because it's being pushed out of the allowed limit... clueless...