Script Generator Help

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


Joined: 24 Feb 2010
Posts: 4

PostPosted: Wed Feb 24, 2010 6:26    Post subject: Script Generator Help Reply with quote
Hello. I've been trying to limit the speed of my roommates computer but have only been able to limit the download speed. Here is the script I'm trying to use for upload:

Code:
TCAU="tc class add dev imq0"
TFAU="tc filter add dev imq0"
TQAU="tc qdisc add dev imq0"
SFQ="sfq perturb 10"
insmod imq
insmod ipt_IMQ
ip link set imq0 up
tc qdisc del dev imq0 root
tc qdisc add dev imq0 root handle 1: htb
tc class add dev imq0 parent 1: classid 1:1 htb rate 960kbit
$TCAU parent 1:1 classid 1:10 htb rate 200kbit ceil 400kbit prio 2
$TQAU parent 1:10 handle 10: $SFQ
$TFAU parent 1:0 prio 2 protocol ip handle 10 fw flowid 1:10
iptables -t mangle -A PREROUTING -s 192.168.1.101 -j MARK --set-mark 10
iptables -t mangle -A PREROUTING -j IMQ --todev 0


I've tried using it in both Firewall and Startup with no luck. I'm using a WRT54GS2 router, and the firmware build is DD-WRT v24-sp2 (10/10/09) micro. Thanks!
Sponsor
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Wed Feb 24, 2010 6:43    Post subject: Reply with quote
Telnet to the router and get the output from these commands.

ifconfig imq0
tc -s class show dev imq0
iptables -t mangle -vnL PREROUTING

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
Styl
DD-WRT Novice


Joined: 24 Feb 2010
Posts: 4

PostPosted: Wed Feb 24, 2010 7:01    Post subject: Reply with quote
Code:
ifconfig imq0

imq0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
-00
          UP RUNNING NOARP  MTU:1500  Metric:1
          RX packets:11 errors:0 dropped:0 overruns:0 frame:0
          TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:30
          RX bytes:1158 (1.1 KiB)  TX bytes:1158 (1.1 KiB)



Code:
tc -s class show dev imq0

class htb 1:1 root rate 1600Kbit ceil 1600Kbit burst 3599b cburst 3599b
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
 lended: 0 borrowed: 0 giants: 0
 tokens: 14745 ctokens: 14745

class htb 1:10 parent 1:1 leaf 10: prio 2 rate 200000bit ceil 320000bit burst 18
49b cburst 2000b
 Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
 lended: 0 borrowed: 0 giants: 0
 tokens: 60620 ctokens: 40960



Code:
iptables -t mangle -vnL PREROUTING

Chain PREROUTING (policy ACCEPT 154K packets, 132M bytes)
 pkts bytes target     prot opt in     out     source               destination
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Wed Feb 24, 2010 7:37    Post subject: Reply with quote
Styl wrote:
Code:
iptables -t mangle -vnL PREROUTING

Chain PREROUTING (policy ACCEPT 154K packets, 132M bytes)
 pkts bytes target     prot opt in     out     source               destination

The script's iptables commands are missing. Do you still have the entire script in your firewall? Try running them via telnet and then check again if they get added correctly.

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
Styl
DD-WRT Novice


Joined: 24 Feb 2010
Posts: 4

PostPosted: Wed Feb 24, 2010 8:10    Post subject: Reply with quote
I had the upload script in Startup to see if it would work there. Moved it to firewall and ran the commands again:

Code:
ifconfig imq0

imq0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
-00
          UP RUNNING NOARP  MTU:1500  Metric:1
          RX packets:876 errors:0 dropped:0 overruns:0 frame:0
          TX packets:876 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:30
          RX bytes:276985 (270.4 KiB)  TX bytes:276985 (270.4 KiB)


Code:
tc -s class show dev imq0

class htb 1:1 root rate 960000bit ceil 960000bit burst 2799b cburst 2799b
 Sent 89 bytes 1 pkts (dropped 0, overlimits 0)
 rate 16bit
 lended: 0 borrowed: 0 giants: 0
 tokens: 18514 ctokens: 18514

class htb 1:10 parent 1:1 leaf 10: prio 2 rate 200000bit ceil 400000bit burst 18
49b cburst 2099b
 Sent 89 bytes 1 pkts (dropped 0, overlimits 0)
 rate 16bit
 lended: 1 borrowed: 0 giants: 0
 tokens: 57737 ctokens: 32965


Code:
iptables -t mangle -vnL PREROUTING

Chain PREROUTING (policy ACCEPT 91 packets, 9292 bytes)
 pkts bytes target     prot opt in     out     source               destination

    2   151 MARK       0    --  *      *       192.168.1.101        0.0.0.0/0
        MARK set 0xa
   88  8505 IMQ        0    --  *      *       0.0.0.0/0            0.0.0.0/0
        IMQ: todev 0
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Wed Feb 24, 2010 16:40    Post subject: Reply with quote
It looks fine now. 192.168.1.101 should be limited to 400kbps up.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
ruriruri
DD-WRT Novice


Joined: 16 Sep 2010
Posts: 3

PostPosted: Thu May 19, 2011 8:32    Post subject: Reply with quote
how to limit MAC address instead of IP using this script?
Aklo
DD-WRT Novice


Joined: 21 Apr 2011
Posts: 41

PostPosted: Fri May 20, 2011 8:00    Post subject: Reply with quote
ruriruri wrote:
how to limit MAC address instead of IP using this script?


you can try to change:

iptables -t mangle -A PREROUTING -s 192.168.1.101 -j MARK --set-mark 10

to:

iptables -t mangle -A PREROUTING -m mac --mac-source 00:00:00:00:00:01 -j MARK --set-mark 10

(change 00:00:00:00:00:01 with the real mac address)

_________________
my speed
Linksys E3000 + v24-sp2 16773 mega + OTRW
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