How can I check multiple list of IPs from IPSet in IPTables with a single rule?

I need to add check two list of IPs because it is too big. I know it is not healthy, but I need to do it that way.

Current rule:

-A INPUT -m state --state NEW -m set ! --match-set trustedlist1 src -j DROP

Now I want to make it something like that:

-A INPUT -m state --state NEW -m set ! --match-set trustedlist1, trustedlist2 src -j DROP

I didnt want to lock myself out.

  • Why -1 for this question? – Sezer Toker Apr 11 at 6:33

Try this

-A INPUT -m state --state NEW -m set ! --match-set trustedlist1 src -m set ! --match-set trustedlist2 src -j DROP

Better solution is arranging ipset size by providing maxelem option. For example;

ipset create trustedlist1 hash:ip maxelem 2000000

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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