0

I would like to block IPs when connectioning on a given port, e.g. 1.1.1.1 on port 443.

I create the ipset like this:

sudo ipset -N blockdaily nethash maxelem 2500000

I can add an IP to it like this:

add blockdaily 1.1.1.1

But when I try and block a port with this:

add blockdaily 1.1.1.1,443

I get an error:

ipset v6.34: Error in line 1: Syntax error: Elem separator in 1.1.1.1,443, but settype hash:net supports none.
Kohjah Breese
  • 171
  • 2
  • 13

1 Answers1

1
  1. To use the port number, you should create appropriate the hash type.

ipset create blockdaily hash:ip,port

  1. You can add elements with similar commands:
ipset add blockdaily 1.1.1.1,tcp:443
ipset add blockdaily 1.1.1.1,udp:53
Anton Danilov
  • 5,082
  • 2
  • 13
  • 23