Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Limiting Bandwidth Per User in Ubuntu

  • 12-04-2010 3:56pm
    #1
    Registered Users, Registered Users 2 Posts: 1,146 ✭✭✭


    Hi All,

    You may have seen some other posts by me about my final year college project. Im implementing a network management website.

    Iv got a lot of the functionality working at this stage but one part is allocating bandwidth.

    Iv got an eircom 3mb broadband connection and I want to be able to split this between users. At the moment I only have my desktop and laptop on the network. Im looking for advice on how i can do this with iptables or the tc tool in ubuntu.

    My website is on an ubuntu virtual machine and written in php. Whatever about running the iptables and tc commands from php I still need to figure out the actual commands i need to use in the first place.

    Can anyone give me some advice on this? Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 1,146 ✭✭✭mossy464


    Sorry I really should have put this in the unix or nets and comms section


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Moved from development.


  • Registered Users, Registered Users 2 Posts: 37,485 ✭✭✭✭Khannie


    What you're looking for mostly is QoS (Quality of Service) and it's complex enough. Google is your friend. This is doable in Linux alright. Haven't done it myself though I've had a look into it. I'm pretty sure tc is not what you want (though it is useful for limiting bandwidth, I don't *think* it gives very fine grained control).


  • Registered Users, Registered Users 2 Posts: 16,288 ✭✭✭✭ntlbell


    You could use a local squid install I would say and force the users through the local cache.

    http://www.squid-cache.org/

    look into delay pools, there might be nicer ways but as it's for a college project this should give you the desired result


  • Registered Users, Registered Users 2 Posts: 218 ✭✭Tillotson


    Or maybe shorewall

    You could look at the source of the webmin module (which I assume is written in Perl) and try implementing that in PHP.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 16,288 ✭✭✭✭ntlbell


    Tillotson wrote: »
    Or maybe shorewall

    You could look at the source of the webmin module (which I assume is written in Perl) and try implementing that in PHP.

    I haven't used shorewall for years, but, I don't think you can limit on a linux "user" with it.


  • Registered Users, Registered Users 2 Posts: 1,146 ✭✭✭mossy464


    I have finally got somewhere now with the bandwidth allocation. :)

    I have ubuntu set up as a router and I am using iptables and the tc command.

    I used some commands I found and altered them to suit my set up but im not exactly sure what each command does. See commands:
    sudo tc qdisc del dev eth1 root
    sudo tc qdisc add dev eth1 root handle 1: htb
    sudo tc class add dev eth1 parent 1: classid 1:1 htb rate 200kbit
    sudo tc class add dev eth1 parent 1:1 classid 1:10 htb rate 200kbit ceil 200kbit prio 2
    sudo tc filter add dev eth1 parent 1:0 prio 2 protocol ip handle 10 fw flowid 1:10
    sudo iptables -t mangle -A POSTROUTING -d 192.168.0.2 -j MARK --set-mark 10
    sudo tc qdisc add dev eth1 ingress
    sudo tc filter add dev eth1 parent ffff: protocol ip handle 50 fw police rate 200kbit mtu 12k burst 10k drop
    sudo iptables -t mangle -A PREROUTING -s 192.168.0.2 -j MARK --set-mark 50
    

    After running these commands I downloaded a file on 192.168.0.2 and it was downloading at around 20kB/s. success it worked.

    I understand the iptables commands, they are marking the packets on the host.

    The tc commands are confusing though like classid 1:1 etc.


Advertisement