I am new to Linux, I used to use windows for years and this is my first time to use Linux "Ubuntu 14.04 LTS"

I am hosting a game-server I was wondering if it is possible to make IPtables to kick if 2+ players logged in the my tcp/udp port "7171" in the same second or block them for 5 seconds I don't need them to be blocked for a long time like the "drop-reject" normal options.

Can someone point me to the right commands or tutorials to make that? Just kick if 2+ players logged in from the same IP to my tcp/udp port "7171" in the same second? or drop/block them for 5 seconds or less thn that?

Thanks in advance I appreciate anyone's answer/help

  • I only know how to do it if the block period (what you want to be 5 seconds) and the 2+ players log in window (what you want to be 1 second) are the same. Would you be interested in such an answer? – Doug Smythies Jan 28 '16 at 20:04
  • Yeah would be good till I find other option. Thanks for your interest. – Łĕğẹňđ Jan 28 '16 at 20:10
  • I want when 2+ players log in the same second they get blocked for 1 second only or kicked without block if possible. – Łĕğẹňđ Jan 28 '16 at 20:35

This answer assumes that somewhere earlier in your iptables rule set there is:

sudo iptables -A INPUT -i eth0 -s -d XXX.YYY.ZZZ.WWW -m state --state ESTABLISHED,RELATED -j ACCEPT

as a by-pass once a connection has already been made.
Then the detect and temporary DROP rules are (I have done 3 seconds):

sudo iptables -A INPUT -i eth0 -m recent --update --hitcount 2 --seconds 3 --name BADGUY_GAME -j DROP
sudo iptables -A INPUT -i eth0 -p tcp -m tcp --dport 7171 -m recent --set --name BADGUY_GAME -j ACCEPT


eth0 is your external I/F. Change to your actual external I/F name
XXX.YYY.ZZZ.WWW  is your external IP address. Change to actual.
  • I know where to put t he first 3 rules but how can I do that one? IPTABLES=/sbin/iptables EXTIF="eth1" <<< Change to your actual external I/F name EXTIP="XXX.YYY.ZZZ.WWW" <<<< Your External IP UNIVERSE=" – Łĕğẹňđ Jan 28 '16 at 21:12
  • Thanks for your answer, that will kick them after log in? after 3 seconds? and where to put the last part? sorry first time to use linux. – Łĕğẹňđ Jan 28 '16 at 21:15
  • I had assumed you would need to merge what I gave you with an existing iptables rule set. I'll revise my answer to be an independent script on its own. It shouldn't kick them after login, that is what the bypass is for. – Doug Smythies Jan 28 '16 at 22:23
  • K thanks a lot I really appreciate your answer, I will try it soon but my dedicated-host went down/off, I think I did something wrong I will call my host providers. – Łĕğẹňđ Jan 29 '16 at 0:23
  • iptables v1.4.21: unknown option "--dport" Try `iptables -h' or 'iptables --help' for more information. – Łĕğẹňđ Jan 29 '16 at 17:21

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.