<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://hlds.pl/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl">
		<id>http://hlds.pl/index.php?action=history&amp;feed=atom&amp;title=Iptables%2FTraffic</id>
		<title>Iptables/Traffic - Historia wersji</title>
		<link rel="self" type="application/atom+xml" href="http://hlds.pl/index.php?action=history&amp;feed=atom&amp;title=Iptables%2FTraffic"/>
		<link rel="alternate" type="text/html" href="http://hlds.pl/index.php?title=Iptables/Traffic&amp;action=history"/>
		<updated>2026-04-21T09:54:31Z</updated>
		<subtitle>Historia wersji tej strony wiki</subtitle>
		<generator>MediaWiki 1.18.1</generator>

	<entry>
		<id>http://hlds.pl/index.php?title=Iptables/Traffic&amp;diff=9158&amp;oldid=prev</id>
		<title>PawelS: +Skrypt.</title>
		<link rel="alternate" type="text/html" href="http://hlds.pl/index.php?title=Iptables/Traffic&amp;diff=9158&amp;oldid=prev"/>
				<updated>2009-09-28T19:50:31Z</updated>
		
		<summary type="html">&lt;p&gt;+Skrypt.&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
			&lt;col class='diff-marker' /&gt;
			&lt;col class='diff-content' /&gt;
		&lt;tr valign='top'&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;← poprzednia wersja&lt;/td&gt;
		&lt;td colspan='2' style=&quot;background-color: white; color:black;&quot;&gt;Wersja z 19:50, 28 wrz 2009&lt;/td&gt;
		&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;== Simple Traffic Logger ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Tworzymy nowy łańcuch:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Tworzymy nowy łańcuch:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; # iptables -N TRAFFIC&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; # iptables -N TRAFFIC&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 31:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Tworzymy plik '''Traffic.sh''':&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Tworzymy plik '''Traffic.sh''':&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt; touch Traffic.sh&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;color: red; font-weight: bold; text-decoration: none;&quot;&gt;I zamieszczamy w nim poniższy skrypt:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; #!/bin/sh&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; #!/bin/sh&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 35:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Linia 40:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; iptables -L -Z TRAFFIC -nvx &amp;gt;&amp;gt; ~/Traffic.dat&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160; iptables -L -Z TRAFFIC -nvx &amp;gt;&amp;gt; ~/Traffic.dat&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background: #eee; color:black; font-size: smaller;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;background: #ffa; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Co dalej? Może jakiś eksport do bazy danych? [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;RRDTool&lt;/del&gt;]]&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;?&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;Co dalej? Może jakiś eksport do bazy danych? &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Jakieś wykresy?&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;== Scripts ==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;background: #cfc; color:black; font-size: smaller;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;* &lt;/ins&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Iptables/Traffic/Tabelizer|Tabelizer&lt;/ins&gt;]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key wiki-wiki:diff:version:1.11a:oldid:9153:newid:9158 --&gt;
&lt;/table&gt;</summary>
		<author><name>PawelS</name></author>	</entry>

	<entry>
		<id>http://hlds.pl/index.php?title=Iptables/Traffic&amp;diff=9153&amp;oldid=prev</id>
		<title>PawelS: Nowy art.</title>
		<link rel="alternate" type="text/html" href="http://hlds.pl/index.php?title=Iptables/Traffic&amp;diff=9153&amp;oldid=prev"/>
				<updated>2009-09-28T16:30:24Z</updated>
		
		<summary type="html">&lt;p&gt;Nowy art.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nowa strona&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Tworzymy nowy łańcuch:&lt;br /&gt;
 # iptables -N TRAFFIC&lt;br /&gt;
&lt;br /&gt;
Podpięcie łańcucha odpowiedzialnego za ruch do nowo utworzonego FORWARD w przypadku bramy i/lub routera, opcjonalnie można dołożyć INPUT i OUTPUT:&lt;br /&gt;
 # iptables -I FORWARD -j TRAFFIC&lt;br /&gt;
&lt;br /&gt;
Możemy także zrobić to po sieciówkach, jeżeli mamy jedną odpowiedzialną za wszystko to będzie to wyglądać tak:&lt;br /&gt;
 # iptables -A TRAFFIC -o eth0 # upstream&lt;br /&gt;
 # iptables -A TRAFFIC -i eth0 # downstream&lt;br /&gt;
&lt;br /&gt;
Co zliczamy? TCP? UDP? ICMP? A może coś bardziej konkretnego? No to bierzemy się za ruch WWW (HTTP requests and response):&lt;br /&gt;
 # iptables -A TRAFFIC -p tcp -m multiport --ports www&lt;br /&gt;
&lt;br /&gt;
Możemy także zrobić tak samo z mailami, a więc:&lt;br /&gt;
 # iptables -A TRAFFIC -p tcp -m multiport --ports pop3,smtp&lt;br /&gt;
&lt;br /&gt;
Można także z konkretnym portem, czyli:&lt;br /&gt;
 # iptables -A TRAFFIC -p tcp --sport 31337&lt;br /&gt;
&lt;br /&gt;
Listing naszego łańcucha:&lt;br /&gt;
 # iptables -L TRAFFIC -nvx&lt;br /&gt;
&lt;br /&gt;
Zerowanie naszego łańcucha:&lt;br /&gt;
 # iptables -Z TRAFFIC&lt;br /&gt;
&lt;br /&gt;
Wyświetla adresy IP i ilość ruchu w bajtach:&lt;br /&gt;
 # iptables -L TRAFFIC -nvx | awk '$1 ~ /^[0-9]+$/ { printf &amp;quot;Adres IP: %s, %d bajtów\n&amp;quot;, $8, $2 }'&lt;br /&gt;
&lt;br /&gt;
Możemy to wszystko trochę bardziej zautomatyzować i przy okazji skomplikować, a więc dodajemy prosty skrypcik do [[cron]]a, niech się wykonuję raz na godzinę. Zależnie od tego jak bardzo chcemy mieć dokładne dane ten czas możemy zmieniać zależnie od potrzeb.&lt;br /&gt;
&lt;br /&gt;
Tworzymy plik '''Traffic.sh''':&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 date &amp;gt;&amp;gt; ~/Traffic.dat&lt;br /&gt;
 iptables -L -Z TRAFFIC -nvx &amp;gt;&amp;gt; ~/Traffic.dat&lt;br /&gt;
&lt;br /&gt;
Co dalej? Może jakiś eksport do bazy danych? [[RRDTool]]?&lt;/div&gt;</summary>
		<author><name>PawelS</name></author>	</entry>

	</feed>