Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

As I have more internet than I can use myself and I have free router I don't use I was thinking about making a free hotspot for the neighbors. Unfortunately, my traffic is limited though so I'd like to have some limits for its day usage. I will install dd-wrt or openwrt on the router to do that but last time I was trying to calculate traffic usage under Linux I had to write my own ulog filter for netfilter and I'd like to avoid doing so now. So is there a product I can use to achieve my goals i.e. break all connections for a day when limit is hit (or shape them down to 32kbps)?

share|improve this question
    
Sounds like your street will become a de facto parking lot before the daily limit. –  random Jul 28 '09 at 4:43
1  
I opened the spot with what's left from my wireless internet half a year ago, it was quite popular but I didn't see any people with laptops around :) –  vava Jul 28 '09 at 8:32
    
You might want to check with your ISP agreement, you may have agreed to not share bandwidth. If so, you might get your bandwidth throttled or have your account terminated. –  NVRAM Sep 29 '09 at 19:13
add comment

4 Answers

up vote 3 down vote accepted

Looks like with modern iptables limiting traffic is rather easy task.

Meet module quota:

iptables -A OUTPUT -p tcp --dport 80 -m quota --quota 1024 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j DROP

This will accept 1K of data and then drop all the connections :) --quota continuously decrementing the counter and when it hits 0 rule does not match any more, so the next one kicks in and block everything.

You can even see how much traffic is left

# iptables -L OUTPUT -v

Chain OUTPUT (policy ACCEPT 3640 packets, 1753K bytes)
pkts bytes target prot opt in out source destination
1 40 ACCEPT tcp -- any any anywhere anywhere tcp dpt:http quota: 984 bytes
0 0 DROP tcp -- any any anywhere anywhere tcp dpt:http

and after a while

# iptables -L OUTPUT -v

Chain OUTPUT (policy ACCEPT 3814 packets, 1773K bytes)
pkts bytes target prot opt in out source destination
8 996 ACCEPT tcp -- any any anywhere anywhere tcp dpt:http quota: 0 bytes
9 504 DROP tcp -- any any anywhere anywhere tcp dpt:http

Looks like if I can install this module on OpenWRT limiting the traffic would be an easy task.

share|improve this answer
add comment

Gargoyle is a firmware like WRT and can calculate quota and limit it per IP. Here's the link.

I wish Tomato and DD-WRT will develop the same feature.

share|improve this answer
add comment

To shape down the traffic, iptables would work on one of the two WRT installations you are considering.

Here is an openwrt forum thread reference for ideas -- Traffic shaping QOS howto;
Two more links.

share|improve this answer
    
Shaping is an option but I might have to shape for really small speeds and it just wouldn't be nice to people. I'd rather count the traffic and shape it down only when limit is hit. –  vava Jul 28 '09 at 4:10
add comment

If you have a computer that's typically always on you can use it as your gateway, and measure statistics on there.


Edit:

since the gateway option is not a possibility, have you ever tried tomato firmware? It has a lot of features, probably much more than you will need. There is ways to disable wireless at certain times, and limit speeds as far as I know. There are also a couple QoS options. My favourite feature in tomato is the fact that you can create cron jobs, these allow you to prune access times for users easily. You could also use cron to check the bandwidth used periodically, and slow down the connection or stop it entirely based on how much has been used.

share|improve this answer
    
No, I don't have desktop computer :) –  vava Jul 28 '09 at 3:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.