Difference between revisions of "Ratelimit"

From Atomicorp Wiki
Jump to: navigation, search
m (Introduction)
m (Configuration)
Line 17: Line 17:
 
First you will need to configure the ports to protect, the rate per port, and the maximum number of concurrent connections for each protected TCP port.  The engine uses two files, one for TCP ports, one for UDP ports.  The files are:
 
First you will need to configure the ports to protect, the rate per port, and the maximum number of concurrent connections for each protected TCP port.  The engine uses two files, one for TCP ports, one for UDP ports.  The files are:
  
''/etc/asl/firewall/rate-limit-tcp
+
''/etc/asl/firewall/rate-limit-tcp''
  
/etc/asl/firewall/rate-limit-udp''
+
''/etc/asl/firewall/rate-limit-udp''
  
 
== TCP ==
 
== TCP ==

Revision as of 16:41, 14 March 2014

Contents

Introduction

ASL 4 introduces rate limiting of TCP and UDP ports. ASL allows you to define the rate at which connections may occur to ports, as well as the maximum number of connections that can be open to a TCP port. This can be used to help with SYN and UDP floods.

For TCP you can define:

  • Per port, rate of connections from a single IP
  • Maxmum concurrent connections to the port (for all IPs)

For UDP

  • Per port, rate of connections from a single IP

Note: Connections from localhost are automatically excluded from all rate limiting.

Configuration

First you will need to configure the ports to protect, the rate per port, and the maximum number of concurrent connections for each protected TCP port. The engine uses two files, one for TCP ports, one for UDP ports. The files are:

/etc/asl/firewall/rate-limit-tcp

/etc/asl/firewall/rate-limit-udp

TCP

The format for the /etc/asl/firewall/rate-limit-tcp file is one line, per port:

port:rate:time_period:time_window:max_concurrent_connections

The fields are:

  • port: The port you want to limit connections to do, for example 80.
  • rate: The maximum number of connections to allow from a single IP, within a specific period of time (defined in time_period and time_window)
  • time_period: The time period to use. The following periods are support: seconds, minutes or hours. For example, "seconds".
  • time_window: The amount of time for the period, for example 1.
  • max_concurrent_connections: The total number of SYN connections allowed from all IPs.

Example:

80:10:seconds:2:100
443:5:seconds:5:10

In this example, the first line means:

  • Port 80 is rate limited
  • To 10 new connections, per every 2 seconds, from the same IP
  • With no more than 100 SYN packets allowed in from all IPs

And the second line means:

  • Port 443 is rate limited
  • To 5 new connections, per every 5 seconds, from the same IP
  • With no more than 10 SYN packets allowed in from all IPs

UDP

The format for the /etc/asl/firewall/rate-limit-udp file is one line, per port:

port:rate:time_period:time_window

  • port: The port you want to limit connections to do, for example 80.
  • rate: The maximum number of connections to allow from a single IP, within a specific period of time (defined in time_period and time_window)
  • time_period: The time period to use. The following periods are support: seconds, minutes or hours. For example, "seconds".
  • time_window: The amount of time for the period, for example 1.

Example:

53:100:seconds:10
2049:100:minutes:1

Note: UDP is connectionless, so there are no concurrent connections.

In this example, the first line means:

  • Port 53 is rate limited
  • To 100 new connections, per every 10 seconds, from the same IP

And the second line means:

  • Port 2049 is rate limited
  • To 100 new connections, per every 1 minute, from the same IP

Enabling

Once you have rate limiting configured, you will need to enable it. Please see this option to enable the engine:

https://www.atomicorp.com/wiki/index.php/ASL_firewall#FW_RATE_LIMIT

And then follow the instructions in this document to configure rate limiting for your system.

Personal tools