<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ilianko.com/index.php?action=history&amp;feed=atom&amp;title=Traffic_control</id>
	<title>Traffic control - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ilianko.com/index.php?action=history&amp;feed=atom&amp;title=Traffic_control"/>
	<link rel="alternate" type="text/html" href="https://ilianko.com/index.php?title=Traffic_control&amp;action=history"/>
	<updated>2026-05-13T17:06:13Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.1</generator>
	<entry>
		<id>https://ilianko.com/index.php?title=Traffic_control&amp;diff=4516&amp;oldid=prev</id>
		<title>Anko: Created page with &quot;&lt;code&gt;&lt;pre&gt; #! /bin/bash NETCARD=eth2 NET2=ppp0  MAXBANDWIDTH=100  # reinit iptables -t mangle -F echo &quot;iptables -t mangle -F&quot; #tc qdisc del dev $NETCARD root handle 3 #tc qdisc ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://ilianko.com/index.php?title=Traffic_control&amp;diff=4516&amp;oldid=prev"/>
		<updated>2013-08-02T08:50:34Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt; #! /bin/bash NETCARD=eth2 NET2=ppp0  MAXBANDWIDTH=100  # reinit iptables -t mangle -F echo &amp;quot;iptables -t mangle -F&amp;quot; #tc qdisc del dev $NETCARD root handle 3 #tc qdisc ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
#! /bin/bash&lt;br /&gt;
NETCARD=eth2&lt;br /&gt;
NET2=ppp0&lt;br /&gt;
&lt;br /&gt;
MAXBANDWIDTH=100&lt;br /&gt;
&lt;br /&gt;
# reinit&lt;br /&gt;
iptables -t mangle -F&lt;br /&gt;
echo &amp;quot;iptables -t mangle -F&amp;quot;&lt;br /&gt;
#tc qdisc del dev $NETCARD root handle 3&lt;br /&gt;
#tc qdisc del dev $NET2 root handle 4&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;tc qdisc del dev $NETCARD root handle 1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tc qdisc add dev $NETCARD root handle 3: htb default 9999&lt;br /&gt;
echo &amp;quot;tc qdisc add dev $NETCARD root handle 1: htb default 9999&amp;quot;&lt;br /&gt;
&lt;br /&gt;
tc qdisc add dev $NET2 root handle 4: htb default 9999&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# create the default class&lt;br /&gt;
tc class add dev $NETCARD parent 3:0 classid 3:9999 htb rate $(( $MAXBANDWIDTH ))kbit ceil $(( $MAXBANDWIDTH ))kbit burst 5k prio 9999&lt;br /&gt;
tc class add dev $NET2 parent 4:0 classid 4:9999 htb rate $(( $MAXBANDWIDTH ))kbit ceil $(( $MAXBANDWIDTH ))kbit burst 5k prio 9999&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# control bandwidth per w&lt;br /&gt;
&lt;br /&gt;
declare -A ipctrl&lt;br /&gt;
# define list of IP and bandwidth (in kilo bits per seconds) below&lt;br /&gt;
ipctrl[172.16.20.2]=&amp;quot;1000&amp;quot;&lt;br /&gt;
ipctrl[172.16.20.1]=&amp;quot;1000&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
mark=0&lt;br /&gt;
for ((i=1;i&amp;lt;=253;i++))&lt;br /&gt;
do&lt;br /&gt;
    ip=&amp;quot;192.168.24.$i&amp;quot;&lt;br /&gt;
    mark=$(( mark + 1 ))&lt;br /&gt;
    bandwidth=700&lt;br /&gt;
&lt;br /&gt;
#echo $ip&lt;br /&gt;
&lt;br /&gt;
    # traffic shaping rule&lt;br /&gt;
#echo &amp;quot;tc class add dev $NETCARD parent 1:0 classid 1:$mark htb rate $(( $bandwidth ))kbit ceil &amp;quot;&lt;br /&gt;
tc class add dev $NETCARD parent 3:0 classid 3:$mark htb rate $(( $bandwidth ))kbit ceil $(( $bandwidth ))kbit burst 5k prio $mark&lt;br /&gt;
tc class add dev $NET2 parent 4:0 classid 4:$mark htb rate $(( $bandwidth ))kbit ceil $(( $bandwidth ))kbit burst 5k prio $mark&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # netfilter packet marking rule&lt;br /&gt;
    iptables -t mangle -A POSTROUTING -s $ip -j CLASSIFY --set-class 4:$mark&lt;br /&gt;
    iptables -t mangle -A POSTROUTING -d $ip -j CLASSIFY --set-class 3:$mark&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
    # filter that bind the two&lt;br /&gt;
    tc filter add dev $NETCARD parent 3:0 protocol ip prio $mark handle $mark fw flowid 1:$mark&lt;br /&gt;
    tc filter add dev $NET2 parent 4:0 protocol ip prio $mark handle $mark fw flowid 1:$mark&lt;br /&gt;
&lt;br /&gt;
 #   echo &amp;quot;IP $ip is attached to mark $mark and limited to $bandwidth kbps&amp;quot;&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Anko</name></author>
		
	</entry>
</feed>