iptables - Limit Connections Per Second


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting iptables - Limit Connections Per Second
# 1  
Old 06-03-2013
iptables - Limit Connections Per Second

Hi,

Sorry for my english. I need a shell script. .

If IP make more than 300 connection attempts to port:80 within 10 seconds
I want block it for 3600 second in iptables.
Thank you ver much for help.
# 2  
Old 06-03-2013
You normally would consider using apache or some other tool to block an ip. Are you trying to stop flooding?
# 3  
Old 06-03-2013
I hardly think you need a shell script for this.

Even iptables is not a suitable solution for this and cannot handle this particular scenario.

The obvious approach would be a rule similar to this (snippet, not full chain):
Code:
iptables -A http_rule -m recent --update --name counter --seconds 10 --hitcount 300 -j do_something

However hitcount is limited to 20 on most recent kernels; any value larger than that will throw an error message since it cannot keep track of more than 20 connections.

This is -as far as I know- harcoded in the kernel and unless you load a custom module or use a non-stadard kernel it won't allow you to go beyond that number.

(300 conns / 10 seconds) is barely equal to (100 conns / 1 second) which is still much larger than 20; not useful.

Try other suggestions like using the tools provided by Apache or a more featured/robust firewall (a HW firewall perhaps, a routing ACL, etc).

Also, it would be more helpful if you explained what is the problem at hand that you're trying to solve instead of how you are trying to solve it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Limit transfer speed rate by iptables Rules

I have D-Link Router DSL-2730U that support busybox OS and iptables version 1.4.0 I managed successfully to block the host for being connect to the internet using the following command block by ip address iptables -I FORWARD -d 192.168.1.6 -j DROP Or By mac source iptables -I... (0 Replies)
Discussion started by: iLinux85
0 Replies

2. Solaris

Passwordless connections

Hi All! Please help me with this situation: I have 3 servers configured with the following network 10.100.48.xx and I have configured on the passwordless connection, and it is working fine. Now the app vendor ask me to configure a 2nd IP address on each of the 3 servers with a different IP... (4 Replies)
Discussion started by: fretagi
4 Replies

3. UNIX for Dummies Questions & Answers

Iptables, port forwarding, 64k connection limit?

I am having an issue with iptables. My server is a RHEL6 64bit system. In my application I have a large number of connected clients ~100k to a particular service. The application works fine when iptables is off, 100k clients are able to connect. However, when I turn iptables on and add a... (1 Reply)
Discussion started by: jtipp3tt
1 Replies

4. Solaris

Limit: stacksize: Can't remove limit

Hi all, I'm using to Solaris machine. When I run a simple script this messenger come out:"limit: stacksize: Can't remove limit". Any one know the way to resolve this problem without reboot the machine? Thanks in advance. (3 Replies)
Discussion started by: Diabolist9
3 Replies

5. UNIX for Dummies Questions & Answers

Routing or Iptables connections by hostname or ip address

edit; I found a solution that works, see thread #3 https://www.unix.com/302417065-post3.html Hi there, I have a small dedicated server that has four ip addresses and by default my httpd sends request using the servers main ip for all outbound connections. I'm quite amateur at routing and... (4 Replies)
Discussion started by: mooofa
4 Replies

6. Cybersecurity

~ IPTables : Limit Incoming UDP Packets With a Certain Length ~

Hello, I am currently trying to limit incoming UDP length 20 packets on a per IP basis to 5 a second using IPTables on a Linux machine (CentOS 5.2). Basically, if an IP is sending more than 5 length 20 UDP packet a second to the local machine, I would like the machine to drop the excess... (1 Reply)
Discussion started by: tomboy123
1 Replies

7. UNIX for Advanced & Expert Users

Problems with connections

Hello everybody, Look, im having problems with connections from other server, i must recieve maximus 5 connections from the other server, when I run 'netstat -A | grep <THE_OTHER_SERVER_IP>' I can see how many connections I have already established, but when they open another connection, i mean... (8 Replies)
Discussion started by: Lestat
8 Replies

8. HP-UX

HP-UX: X connections...?

Hello All, I have 2 qries about X connections on HP-UX : 1.How/where to determine whether "X connections" to the server are controlled. 2. How/where to determine whether "X11 connection" are tunnelled via ssh. 3. How/where to determine the "Time in minutes before unattended X terminals... (0 Replies)
Discussion started by: abhayh
0 Replies

9. UNIX for Dummies Questions & Answers

Establishing connections

Hello there, just a quick question.....Can someone please explain the concept that enables you to establish a connection using the same userId Thanx (1 Reply)
Discussion started by: BigTool4u2
1 Replies

10. UNIX for Advanced & Expert Users

Trace connections

In my organization in order for anyone to go to any Unix server they have to go through "SERVER A" and login as themselves. Then people are free to go enywhere they please. For example: SERVER A, loggs in as himself telnets to SERVER B, loggs in as guest telnets to SERVER C, loggs in as... (8 Replies)
Discussion started by: jraitsev
8 Replies
Login or Register to Ask a Question