<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Около сетевой Блог &#187; REJECT</title>
	<atom:link href="http://feyhoa.org.ua/archives/tag/reject/feed" rel="self" type="application/rss+xml" />
	<link>http://feyhoa.org.ua</link>
	<description>Новости телекоммуникаций, производителей оборудования, електронных гаджетов и программного обеспечения. Советы настройки Windows и Linux.</description>
	<lastBuildDate>Sat, 11 Feb 2012 22:49:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Linux: IpTables ограничиваем количество соединений с одного ip</title>
		<link>http://feyhoa.org.ua/archives/866</link>
		<comments>http://feyhoa.org.ua/archives/866#comments</comments>
		<pubDate>Mon, 08 Feb 2010 13:33:35 +0000</pubDate>
		<dc:creator>Ioann</dc:creator>
				<category><![CDATA[Админим]]></category>
		<category><![CDATA[Виртуальный учебник]]></category>
		<category><![CDATA[DROP]]></category>
		<category><![CDATA[Ip]]></category>
		<category><![CDATA[IpTables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[REJECT]]></category>

		<guid isPermaLink="false">http://feyhoa.org.ua/?p=866</guid>
		<description><![CDATA[<p><a href="http://feyhoa.org.ua/wp-content/uploads/2010/01/ubuntulogo-96x96.png" rel="lightbox[866]"></a>Очень часто мы сталкиваемся с необходимостью ограничить количество соединений с одного хоста. Эта задача актуальна для администраторов, которые не хотят получить переполнение стека tcp/ip из-за пользователя который решил включить торрент клиент и забыл выключить DHT.<br /> <br /> [ad#ad-2]<br /> IpTables синтаксис команды ограничения соединений: </p> /sbin/iptables -A INPUT -p tcp --syn --dport [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://feyhoa.org.ua/wp-content/uploads/2010/01/ubuntulogo-96x96.png" rel="lightbox[866]"><img src="http://feyhoa.org.ua/wp-content/uploads/2010/01/ubuntulogo-96x96.png" alt="Linux: IpTables ограничиваем количество соединений с одного ip" title="ubuntulogo-96x96" width="96" height="96" class="alignleft size-full wp-image-65" /></a>Очень часто мы сталкиваемся с необходимостью ограничить количество соединений с одного хоста. Эта задача актуальна для администраторов, которые не хотят получить переполнение стека tcp/ip из-за пользователя который решил включить торрент клиент и забыл выключить DHT.<br />
<span id="more-866"></span><br />
[ad#ad-2]<br />
<strong>IpTables синтаксис команды ограничения соединений: </strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">/sbin/iptables -A INPUT -p tcp --syn --dport $port -m connlimit --connlimit-above N -j REJECT --reject-with tcp-reset
# save the changes see iptables-save man page, the following is redhat and friends specific command
service iptables save</pre></div></div>

<p><strong>Пример ограничения количества соединений на порт ssh с одного ip исспользуя IpTables </strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">/sbin/iptables  -p tcp --syn --dport 22 -m connlimit --connlimit-above 3 -j REJECT
# save the changes see iptables-save man page, the following is redhat and friends specific command
service iptables save</pre></div></div>

<p><strong>Пример ограничения количества соединений на порт http с одного ip исспользуя IpTables </strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">/sbin/iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 -j REJECT --reject-with tcp-reset
# save the changes see iptables-save man page, the following is redhat and friends specific command
service iptables save</pre></div></div>

<p><strong>Пример ограничения количества соединений на порт http с с одной сети  исспользуя IpTables </strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">/sbin/iptables  -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 --connlimit-mask 24 -j REJECT --reject-with tcp-reset
# save the changes see iptables-save man page
service iptables save</pre></div></div>

<p><strong>Пример ограничения количества соединений на порт http с одного ip если он отсылает более 10 пакетов в 100 секунд  исспользуя IpTables </strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">#!/bin/bash
IPT=/sbin/iptables
# Max connection in seconds
SECONDS=100
# Max connections per IP
BLOCKCOUNT=10
# ....
# ..
# default action can be DROP or REJECT
DACTION=&quot;DROP&quot;
$IPT -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --set
$IPT -A INPUT -p tcp --dport 80 -i eth0 -m state --state NEW -m recent --update --seconds ${SECONDS} --hitcount ${BLOCKCOUNT} -j ${DACTION}
# ....
# ..</pre></div></div>

<p><strong>Пример проверки работоспособности указанных правил IpTables</strong></p>

<div class="wp_syntax"><div class="code"><pre class="language" style="font-family:monospace;">#!/bin/bash
ip=&quot;10.10.10.10&quot;
port=&quot;80&quot;
for i in {1..100}
do
  # коннектимся, ничего не делаем  и выходим :) 
  echo &quot;exit&quot; | nc ${ip} ${port};
done</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://feyhoa.org.ua/archives/866/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

