I have a work to write a iptables rules to limit the number of physical devices to connect my server, I have tried hashlimit, but it seems not work, below are my rules:
iptables -I INPUT 1 -p tcp -m hashlimit --hashlimit 1000/s --hashlimit-mode srcip,srcport --hashlimit-name hosts --hashlimit-htable-size 1 -j ACCEPT iptables -I INPUT 2 -j REJECT
In the first line, I did a limit the to size of hashlimit, it's just 1, so according to the instructions about hashlimit from websit hashlimit of iptables, it's said:
This sets the maximum available buckets to be used. In this example, it means that a maximum of 500 ports can be open and active at the same time.
So, I guess if I set limit to 1, it's just allow one tcp connection keeped, but when I try another tcp connection with nc, I found that I still can get the connection work, so any tips?