[cod] banning people. & Perl Script to Kick high pings

Jason Maderios jason at maderios.org
Mon Dec 29 10:03:09 EST 2003


Iptables works real well.   Sample is below.  If you are running RedHat just
copy this file to /etc/sysconfig/iptables
then on the command line type: service iptables restart

Then just edit this file and restart iptables to add new bans.  You can even
ban blocks of addr's for those pesky bastards that just do no get the hint.

If you are already running iptables you will need to just add new rules.
This is much more efficiant to run than changing routing statements.

Also iptables is much more powerfull and you can do things like redirecting
incoming request to other IP's this is just a simple sample of how to ban
people.

Jason Maderios
Unix Systems Administrator

--------Begin Sample----------
# Generated by iptables-save v1.2.6a on Mon May 12 21:41:16 2003
*nat
:PREROUTING ACCEPT [1098675:40639041]
:POSTROUTING ACCEPT [8745:1579105]
:OUTPUT ACCEPT [8745:1579105]
COMMIT
# Completed on Mon May 12 21:41:16 2003
# Generated by iptables-save v1.2.6a on Mon May 12 21:41:16 2003
*filter
:INPUT ACCEPT [112497913:8530929287]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [82246263:23469965555]
:rejectlog - [0:0]
[0:0] -A INPUT -s 65.41.7.122 -j rejectlog
[0:0] -A INPUT -s 24.239.129.82 -j rejectlog
[0:0] -A INPUT -s 68.38.106.222 -j rejectlog
[0:0] -A INPUT -s 12.207.102.114 -j rejectlog
[0:0] -A INPUT -s 24.196.202.43 -j rejectlog
[0:0] -A INPUT -s 68.106.171.138 -j rejectlog
[0:0] -A INPUT -s 66.220.231.241 -j rejectlog
[4579:282917] -A rejectlog -j LOG --log-prefix "REJECTED:"
[4579:282917] -A rejectlog -j REJECT --reject-with icmp-port-unreachable
COMMIT
# Completed on Mon May 12 21:41:16 2003
-------------End Sample------------



For this perl script to work you need a working copy of rcon for linux.
This is provided just to give ideas of what can be done.  I am working on a
full version that will not need the outside rcon tool and will kick by
determining the avg ping of players and kick anyone over a percentage above
the average until a satisfactory average is obtained.  I have this script
running from cron on my COD server which allows 64 players.  For the game to
be playable I have to keep the pings down.  If you would like to see a big
arena check out 66.179.164.17


---Begin---
#!/usr/bin/perl


@rcon = `/var/COD/bin/rcon.sh status`;
$numplay = $#rcon - 5;

if ($numplay > 0) { $hiping = 350;}
if ($numplay > 10) { $hiping = 300;}
if ($numplay > 15) { $hiping = 250;}
if ($numplay > 20) { $hiping = 200;}
if ($numplay > 25) { $hiping = 150;}
if ($numplay > 30) { $hiping = 125;}
if ($numplay > 40) { $hiping = 115;}
if ($numplay > 50) { $hiping = 105;}
if ($numplay > 99) { $hiping = 100;}


while (@rcon) {
$line = shift @rcon;
chomp $line;
$id = substr($line,0,3);
$id =~ s/ *//g;
$score = substr($line,4,5);
$score =~ s/ *//g;
$ping = substr($line,10,4);
$ping =~ s/ *//g;
$player = substr($line,15,15);
$player =~ s/ *//g;
if ($id > 11 ) { &check_ping; }
}


sub check_ping {

if ($ping =~ 999) {
        $ping = 0;
        }
if ($ping > $hiping ) {
        print "ID=$id SC=$score PN=$ping\n";
        print "Kicking ID $id for a ping of $ping current # of players is
$numplay curret maxping is $hiping\n";
        sleep (2);
        system ("/var/COD/bin/rcon.sh clientkick $id");
        }
}
exit (0)
--End--





More information about the Cod mailing list