in reply to Block IP addresses with IO::Socket

I think such blocking must be done on a lower TCP level, as Perl shields us from the ugly state machine that is a TCP connection - my way would be to set up a (simplicistic) firewall and manipulate the rules to block packets from within the program:

  1. First connection comes in
  2. Program changes the IP tables to block all further SYN packets from the remote IP to the local server port:
    `ipmasq -A ipblock -i eth0 -o localhost --dest-port 8000 --remote-ip 192.168.1.100`
  3. Second connection comes in and gets blocked by the firewall

You should still do the second check in your program, and you should maybe clean/expire the firewall blocks from time to time.

In the end I think that a firewall will be necessary anyway, as you have a machine connected to the internet.

perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web

Replies are listed 'Best First'.