A firewall script to restrict bandwith on LAN

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
Damiano
DD-WRT Novice


Joined: 16 Jul 2006
Posts: 8
Location: Poland

PostPosted: Sun Jul 16, 2006 11:19    Post subject: A firewall script to restrict bandwith on LAN Reply with quote
Code:
tc qdisc del root dev eth0 2>/dev/null
tc qdisc del root dev ppp0 2>/dev/null
iptables -t mangle -D POSTROUTING -o ppp0 -j MYSHAPER-OUT 2>/dev/null
iptables -t mangle -F MYSHAPER-OUT 2>/dev/null
iptables -t mangle -X MYSHAPER-OUT 2>/dev/null
#DOWNLOAD
tc qdisc add dev eth0 root handle 1:0 htb
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 9000kbit ceil 9000kbit
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 480kbit ceil 480kbit
tc class add dev eth0 parent 1:1 classid 1:3 htb rate 8500kbit ceil 8500kbit
tc class add dev eth0 parent 1:2 classid 1:4 htb rate 360kbit ceil 480kbit
tc class add dev eth0 parent 1:2 classid 1:5 htb rate 96kbit ceil 128kbit
tc filter add dev eth0 protocol ip preference 1 parent 1:0 u32 match ip \
src 192.168.1.1 flowid 1:3
tc filter add dev eth0 protocol ip preference 1 parent 1:0 u32 match ip \
dst 192.168.1.2 flowid 1:4
tc filter add dev eth0 protocol ip preference 1 parent 1:0 u32 match ip \
dst 192.168.1.3 flowid 1:5
tc qdisc add dev eth0 parent 1:3 handle 3:0 sfq perturb 10
tc qdisc add dev eth0 parent 1:4 handle 4:0 sfq perturb 10
tc qdisc add dev eth0 parent 1:5 handle 5:0 sfq perturb 10
#UPLOAD
tc qdisc add dev ppp0 root handle 1:0 htb
tc class add dev ppp0 parent 1:0 classid 1:1 htb rate 120kbit ceil 120kbit quantum 16
tc class add dev ppp0 parent 1:1 classid 1:2 htb rate 40kbit ceil 96kbit quantum 4
tc class add dev ppp0 parent 1:1 classid 1:3 htb rate 40kbit ceil 96kbit quantum 4
tc class add dev ppp0 parent 1:1 classid 1:4 htb rate 40kbit ceil 96kbit quantum 4
tc qdisc add dev ppp0 parent 1:2 handle 2:0 sfq perturb 10
tc qdisc add dev ppp0 parent 1:3 handle 3:0 sfq perturb 10
tc qdisc add dev ppp0 parent 1:4 handle 4:0 sfq perturb 10
tc filter add dev ppp0 protocol ip preference 1 parent 1:0 handle 20 fw flowid 1:2
tc filter add dev ppp0 protocol ip preference 1 parent 1:0 handle 21 fw flowid 1:3
tc filter add dev ppp0 protocol ip preference 1 parent 1:0 handle 22 fw flowid 1:4
iptables -t mangle -N MYSHAPER-OUT
iptables -t mangle -I POSTROUTING -o ppp0 -j MYSHAPER-OUT
iptables -t mangle -A MYSHAPER-OUT -p tcp -s 192.168.1.2 -j MARK --set-mark 21
iptables -t mangle -A MYSHAPER-OUT -p tcp -s 192.168.1.3 -j MARK --set-mark 22
iptables -t mangle -A MYSHAPER-OUT -m mark --mark 0 -j MARK --set-mark 20


Hi,
Does that script work on DD-WRT Question
Eventually what i must to correct - i think that something is'nt compatible with DD-WRT but i don't know what Cool

_________________
Greetings and sorry about my english Wink
DaMiAnO

Sponsor
GeeTek
DD-WRT Guru


Joined: 06 Jun 2006
Posts: 3763
Location: I'm the one on the plate.

PostPosted: Sun Jul 16, 2006 15:20    Post subject: Reply with quote
Damiano, where did you find that script ? I am happy to try other firmware if I need to so I can limit bandwidth. I tried DD-WRT "Special" QOS version, but was very dissapointed with the performance. It did not have many options for limiting service, and it did not seem to function properly with what simple job I gave it to do. Sad
_________________
http://69.175.13.131:8015 Streaming Week-End Disco. Station Ripper V 1.1 will do.
Damiano
DD-WRT Novice


Joined: 16 Jul 2006
Posts: 8
Location: Poland

PostPosted: Sun Jul 16, 2006 19:06    Post subject: Reply with quote
GeeTek wrote:
Damiano, where did you find that script ? I am happy to try other firmware if I need to so I can limit bandwidth. I tried DD-WRT "Special" QOS version, but was very dissapointed with the performance. It did not have many options for limiting service, and it did not seem to function properly with what simple job I gave it to do. Sad

I find it on webs about Mandriva (Mandrake) linux Smile
That script do not work properly - he can only limit all bandwith Crying or Very sad
Users with ip 1 and 2 in real have the same limit = 520/8 Confused

_________________
Greetings and sorry about my english Wink
DaMiAnO

dcd
DD-WRT User


Joined: 08 Jun 2006
Posts: 90

PostPosted: Sun Jul 16, 2006 19:14    Post subject: Reply with quote
buy a cisco router or setup a bsd box as a gateway and configure pipes
Damiano
DD-WRT Novice


Joined: 16 Jul 2006
Posts: 8
Location: Poland

PostPosted: Sun Jul 16, 2006 19:59    Post subject: Reply with quote
dcd wrote:
buy a cisco router or setup a bsd box as a gateway and configure pipes

You must be joking Wink
I want to limit 2 users only Smile
I don't understand why this not working...

GeeTek wrote:
Damiano, where did you find that script ? I am happy to try other firmware if I need to so I can limit bandwidth. I tried DD-WRT "Special" QOS version, but was very dissapointed with the performance. It did not have many options for limiting service, and it did not seem to function properly with what simple job I gave it to do. Sad

Can you limit the bandwith for 1 ip from list of users Question

_________________
Greetings and sorry about my english Wink
DaMiAnO

GeeTek
DD-WRT Guru


Joined: 06 Jun 2006
Posts: 3763
Location: I'm the one on the plate.

PostPosted: Sun Jul 16, 2006 23:09    Post subject: Reply with quote
No, that part of the system is part of the stuff that does not seem to work. Rolling Eyes
_________________
http://69.175.13.131:8015 Streaming Week-End Disco. Station Ripper V 1.1 will do.
Damiano
DD-WRT Novice


Joined: 16 Jul 2006
Posts: 8
Location: Poland

PostPosted: Mon Jul 17, 2006 16:31    Post subject: Reply with quote
GeeTek wrote:
No, that part of the system is part of the stuff that does not seem to work. Rolling Eyes

That very strange - on other firmware like Thibor is working Rolling Eyes
Maybe is blocked or something...

Even simple script like this doesn't work...

Code:
tc qdisc del root dev eth0
tc qdisc add dev eth0 root handle 1:0 htb
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 520kbit ceil 520kbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 96kbit ceil 120kbit
tc filter add dev eth0 protocol ip parent 1:0 u32 match ip dst 192.168.1.3 flowid 1:10


Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes Rolling Eyes

_________________
Greetings and sorry about my english Wink
DaMiAnO

BigL
DD-WRT User


Joined: 07 Jun 2006
Posts: 79

PostPosted: Mon Jul 17, 2006 19:38    Post subject: Reply with quote
In above script everything works except first line. But this is normal - you reffer to root eth0 which is not created. Remember that you cannot simply copy&paste scripts from "normal" linux since they base on modifications to default interface eth0. But interfaces have different names in DD-WRT.
Damiano
DD-WRT Novice


Joined: 16 Jul 2006
Posts: 8
Location: Poland

PostPosted: Mon Jul 17, 2006 21:24    Post subject: Reply with quote
BigL wrote:
In above script everything works except first line. But this is normal - you reffer to root eth0 which is not created. Remember that you cannot simply copy&paste scripts from "normal" linux since they base on modifications to default interface eth0. But interfaces have different names in DD-WRT.

Interfaces that is the clue Twisted Evil
TY @BigL

_________________
Greetings and sorry about my english Wink
DaMiAnO

Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum