Shaper script.

Taking care of your Linux box.

Shaper script.

Postby darkstar » Sat Sep 06, 2008 11:45 pm

I recently got charge of lab admin for few months my system is running shaper script i do not know the version but i want to restrict the bandiwth to all users to 128 kbps and the ip with 10.10.20.130 with 512 kbps.Here is the script


Code: Select all

# internal interface
#
IFACE="eth1"

# Bandwidth rate in kilobit/second
#
CRATE="128Kbit"

# first three octet of ip range with last DOT
# i.e.
# "10.0.0."  or  "192.168.0."
# please note this script always exclude first and last (broadcast) ip
# i.e. 10.0.0.1 and 10.0.0.255
#
ipdstprefix="10.10.20."

# tc path
#
tcpth="/sbin/tc"

darkstar
Cadet
 
Posts: 4
Joined: Sun Oct 14, 2007 9:51 am
WLM: ali_ali627@hotmail.com
Yahoo Messenger: hassam.ali911@yahoo.com

Postby x2oxen » Mon Sep 08, 2008 9:20 am

Is this full full script ??
Muhammad Usman
+92-321-6640501
Chemonics International
http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Postby darkstar » Mon Sep 08, 2008 8:48 pm

yes
darkstar
Cadet
 
Posts: 4
Joined: Sun Oct 14, 2007 9:51 am
WLM: ali_ali627@hotmail.com
Yahoo Messenger: hassam.ali911@yahoo.com

Postby zaib » Mon Sep 08, 2008 9:29 pm

darkstar wrote:yes


This script is incomplete. Check again, maybe you are copy pasting it fully. as it donot have any function to implement.
Regards,

SYED JAHANZAiB

web: http://aacable.wordpress.com
msn: aacable@hotmail.com
zaib
Naik
 
Posts: 97
Joined: Thu Jan 10, 2008 3:11 pm
Website: http://aacable.wordpress.com
WLM: aacable@hotmail.com
Yahoo Messenger: johny_reico@yahoo.com
Location: Karachi

Postby x2oxen » Mon Sep 08, 2008 9:57 pm

Script is not even started very well yet!
Muhammad Usman

+92-321-6640501

Chemonics International

http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Postby nomankhn » Tue Sep 09, 2008 5:36 am

Ah......

that script is created by hamid khan , compucated something his id on linuxpakistan.

Thanks,
Noman Liaquat
nomankhn
Colonel
 
Posts: 714
Joined: Wed Aug 07, 2002 8:00 pm

Postby x2oxen » Tue Sep 09, 2008 9:00 am

How you can be so sure noman as even variables are not properly defined yet in the script!
Muhammad Usman

+92-321-6640501

Chemonics International

http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad

Postby nomankhn » Wed Sep 10, 2008 12:00 am

http://www.linuxpakistan.net/forum2x/vi ... ontrolling

he suggest his script some other post and compiled his main bash script with shc, so no one knows what is inside that, actually i also tested his script, looks like fake thats why i didnt use.

Thanks,
Noman Liaquat
nomankhn
Colonel
 
Posts: 714
Joined: Wed Aug 07, 2002 8:00 pm

Re:

Postby LinuxFreaK » Wed Sep 10, 2008 9:04 am

Dear darkstar,
Salam,

Use this script.

Code: Select all

#!/bin/bash
#
# Linux Traffic Shaper Script (LTSS) version 0.1 beta (5/27/04)
# -------------------------------------------------------------------------------------------------
# (c) Copyright 2004, Matt Goebel (mlg9000@yahoo.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# Credit:
# -------------------------------------------------------------------------------------------------
# Daniel Leaberry's tcstart script
# Wondershaper 1.1a
# knowplace.org and the narc firewall
#
# Purpose / Function:
# -------------------------------------------------------------------------------------------------
# This script was written to provide traffic shaping for my own personal LAN's cable Internet
# connection. It ensures that regular network traffic does not interfere with my VOIP service.
# (Vonage.com) It also prioritizes other forms of interactive traffic so that uploads do not have as
# big an impact on them as they otherwise would.  Only upstream traffic is shaped as downstream traffic
# is largely beyond our control.  At the moment this is a very simple script.  In the
# future it's functionality may be expanded upon and improved.  If you find this script useful,
# if you find any errors, or you have suggestions on ways to improve it, please let me know.
#
# Prerequisites:
# -------------------------------------------------------------------------------------------------
# 1. A modern Linux kernel /w HTB (http://luxik.cdi.cz/~devik/qos/htb/index2.htm) support enabled
#    and the Netfilter module ipt_CLASSIFY.ko available (ipt_CLASSIFY.o for 2.4 kernels)
# 2. iproute /w tc that supports HTB
# 3. ipchains with CLASSIFY support (specifically libipt_CLASSIFY.so must be included)
# 4. A VOIP router from any provider, or VOIP software
#
# Usage:
# -------------------------------------------------------------------------------------------------
# Start the script - "ltss start"
# Stop the script - "ltss stop"
# Restart the script - "ltss restart"
# Show the Status - "ltss status"
#
# Note: Check your firewall rules to be sure this does not conflict with the rules set there
#
# Tested and known to work on (let me know so I can add these):
# - Fedora Core 2 (stock kernel, out of the box no special steps required)
#
# Installation:
# -------------------------------------------------------------------------------------------------
# 1. Modify the listed variables below to match your needs
# 2. Make this script executable and owned by root (chown root:root ltss, chmod 700 ltss)
# 3. Place this script in your start files (Optional)
#
# Variables (change these as needed):
# -------------------------------------------------------------------------------------------------

TC=/usr/sbin/tc             # Path to the tc command
IPTABLES=/usr/sbin/iptables # Path to the iptables command
UPSTREAM="450Kbit"      # Tweak this as needed (~90% total upload bandwidth is a good start)
EXTINT="eth0"           # External Interface
VOIP1="5060:5061"       # First port (or range) used by VOIP (UDP)
VOIP2="10000:20000"     # Second port range used by VOIP (Optional UDP - required for Vonage)
FPRIORITY="200Kbit"     # VOIP bandwidth req. (2x max bandwidth required for highest quality call, used for 3 way calling)
SPRIORITY="150Kbit"     # Interactive and other higher priority bandwidth req.
LASTPRIORITY="100Kbit"  # Everything else (should be the rest of the bandwidth you have left)
HP="domain,http,pop3,imap,https,imaps,ftp"  # TCP Traffic you want to give priority to (SSH already included
HPTCP="3724"                # Other TCP traffic you want to give priority to (Port or Range of Ports)
HPUDP="53"                # Other UDP traffic you want to give priority to (Port or Range of Ports)


# Script portion (should not need modification):
# -------------------------------------------------------------------------------------------------

if [ "$1" == "start" ] || [ "$1" == "restart" ] || [ "$1" == "stop" ]; then
        # Flush everything
        $TC qdisc del dev $EXTINT root 2> /dev/null > /dev/null
        fi
if [ "$1" == "start" ] || [ "$1" == "restart" ]; then
        # Start Traffic Shaper
        if [ "$1" == "start" ]; then
                echo "Starting Traffic Shaper........"
                fi
        if [ "$1" == "restart" ]; then
                echo "Restarting Traffic Shaper........"
                fi
        # Load CLASSIFY module
        modprobe ipt_CLASSIFY
        # Setup classes
        $TC qdisc add dev $EXTINT root handle 1: htb default 12 r2q 3
        $TC class add dev $EXTINT parent 1: classid 1:1 htb rate $UPSTREAM
        $TC class add dev $EXTINT parent 1:1 classid 1:10 htb rate $FPRIORITY ceil $UPSTREAM prio 0
        $TC class add dev $EXTINT parent 1:1 classid 1:11 htb rate $SPRIORITY ceil $UPSTREAM prio 1
        $TC class add dev $EXTINT parent 1:1 classid 1:12 htb rate $LASTPRIORITY ceil $UPSTREAM prio 2
        $TC qdisc add dev $EXTINT parent 1:10 handle 10: sfq perturb 10
        $TC qdisc add dev $EXTINT parent 1:11 handle 11: sfq perturb 10
        $TC qdisc add dev $EXTINT parent 1:12 handle 12: sfq perturb 10
        # VOIP traffic
        iptables -t mangle -A POSTROUTING -o $EXTINT -p udp --dport $VOIP1 -j CLASSIFY --set-class 1:10
        if [ "$VOIP2" != "" ]; then
                iptables -t mangle -A POSTROUTING -o $EXTINT -p udp --dport $VOIP2 -j CLASSIFY --set-class 1:10
                fi
        # Setup secondary traffic
        # Give "overhead" packets priority
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --syn -m length --length 40:68 -j CLASSIFY --set-class 1:11
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --tcp-flags ALL SYN,ACK -m length --length 40:68 -j CLASSIFY --set-class 1:11
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --tcp-flags ALL ACK -m length --length 40:100 -j CLASSIFY --set-class 1:11
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --tcp-flags ALL RST -j CLASSIFY --set-class 1:11
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --tcp-flags ALL ACK,RST -j CLASSIFY --set-class 1:11
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --tcp-flags ALL ACK,FIN -j CLASSIFY --set-class 1:11
        # Interactive SSH traffic
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --sport ssh -m length --length 40:100 -j CLASSIFY --set-class 1:11
        iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp --dport ssh -m length --length 40:100 -j CLASSIFY --set-class 1:11
        # Interactive traffic
        if [ "$HP" != "" ]; then
                iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp -m multiport --dport $HP -j CLASSIFY --set-class 1:11
                fi
        # improve ICMP results
        tc filter add dev $EXTINT parent 1:0 protocol ip prio 10 u32 \
               match ip protocol 1 0xff flowid 1:10

        # Other TCP/UDP traffic
        if [ "$HPTCP" != "" ]; then
                iptables -t mangle -A POSTROUTING -o $EXTINT -p tcp -m multiport --dport $HPTCP -j CLASSIFY --set-class 1:11
                fi
        if [ "$HPUDP" != "" ]; then
                iptables -t mangle -A POSTROUTING -o $EXTINT -p udp -m multiport --dport $HPUDP -j CLASSIFY --set-class 1:11
                fi
        echo "Done."
        exit 0
        fi
if [ "$1" == "stop" ]; then
        # Stop Traffic Shaper
        echo "Stopping Traffic Shaper........"
        echo "Done."
        exit 0
        fi
if [ "$1" == "status" ]; then
        # Show Status
        echo "Current Traffic Shaper Status:"
        echo "---------------------------------------------------------------------------"
        tc -s qdisc ls dev $EXTINT
        tc -s class ls dev $EXTINT
        exit 0
        fi
if [ "$1" != "start" ] && [ "$1" != "restart" ] && [ "$1" != "stop" ] && [ "$1" != "status" ]; then
        echo "Bad or missing parameters"
        echo "Usage: { start | stop | restart | status }"
        echo "start          = Start traffic shaper"
        echo "stop           = Stop traffic shaper"
        echo "restart        = Restart traffic shaper"
        echo "status         = Show status of traffic shaper"
        exit 1
        fi


Best Regards.
Farrukh Ahmed
LinuxFreaK
Site Admin
 
Posts: 5132
Joined: Fri May 02, 2003 10:24 am
ICQ: 82075802
Website: http://www.linuxpakistan.net/wiki/index.php?pagename=LinuxFreak
WLM: f4fahmed@hotmail.com
Yahoo Messenger: f4fahmed@yahoo.com
AOL: linuxpakistan@aol.com
Location: Karachi

Postby mudasir » Thu Sep 11, 2008 6:42 am

Hi,

Dear Mr. Darkstar,

The code you pasted is a ".conf" file, and this script is written by Mr. Asif Bakali.

You can download a shaper script from

http://www.geocities.com/cool_mudasir/linux/shaper.zip

Read the readme file in that script, it will let you know how can you modify bandwidth of individual IP's. By default this script was written for ip range "192.168.0" so you have to replace "192.168.0" with "10.10.20".

You can do that using any text editor you like.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby compucated » Tue Oct 14, 2008 10:07 pm

Posting this just to thing make straight:

>>that script is created by hamid khan , compucated something his id on linuxpakistan.

My name is Hamid Ashraf, not the Khan at last.

>> he suggest his script some other post and compiled his main bash script
>> with shc, so no one knows what is inside that, actually i also tested his
>> script, looks like fake thats why i didnt use.

So you think its fake, just because its packed, so you also think regarding Billions of compiled\packed applications are also fake? , just because they are packed....
ahan, if you have security concern why not to backtrace the application?


>>The code you pasted is a ".conf" file, and this script is written by Mr. Asif Bakali.
>> You can download a shaper script from
>> http://www.geocities.com/cool_mudasir/linux/shaper.zip

Not even that was wrote by me, but also the one you posted & dozens of others circulating these days in Pakistan are altered code of my original stuff.

Shame on you to claiming the code by just altering or adding FAQ.
compucated
Naik
 
Posts: 75
Joined: Mon Oct 13, 2003 5:06 am
WLM: compucated(at)msn(dot)com
Yahoo Messenger: activatedpower(at)yahoo(dot)com
Location: Karachi, Pakistan

Postby mudasir » Wed Oct 15, 2008 2:52 am

AOA,

Dear Hamid bhai,

I know it is an altered version of your script, as its open source every one is free to alter stuff and they can put their name on it. So if you want your work not to be used or altered then complie it and then distribute it.

However the script is a bit old and i have not used this script for last about 1 year. I was using my own custom made package based script. Now currently i am using Mikrotik so no one can claim that i did that or i did that.

Hope you dont mind.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby compucated » Wed Oct 15, 2008 3:04 pm

mudasir wrote:I know it is an altered version of your script, as its open source every one is free to alter stuff and they can put their name on it. So if you want your work not to be used or altered then complie it and then distribute it.


I appreciate your polite attitude, however you have some misconception towards opensource.

This is right that one is free to alter/modify the original code, but must intact the prominent notices stating that he is modifying it.
See Section 6 @http://www.opensource.org/licenses/afl-3.0.php
Did you or anyone else mention that in code?

mudasir wrote:However the script is a bit old and i have not used this script for last about 1 year. I was using my own custom made package based script. Now currently i am using Mikrotik so no one can claim that i did that or i did that.
Hope you dont mind.


yup, thats right, not just old but the work from me when I was just learning & experimenting those tools.
compucated
Naik
 
Posts: 75
Joined: Mon Oct 13, 2003 5:06 am
WLM: compucated(at)msn(dot)com
Yahoo Messenger: activatedpower(at)yahoo(dot)com
Location: Karachi, Pakistan

Postby mudasir » Wed Oct 15, 2008 7:06 pm

AOA,

Dear Hamid bhai,

The script which i got my hand on did not had any name of the owner or what so ever, so i altered it and provided the script to the community.
Kind Regards
Mudasir Mirza (RHCE)
(+971)55-1045754
http://www.crystalnetworks.org
http://www.diglinux.com
mudasir
Captain
 
Posts: 565
Joined: Tue Oct 17, 2006 5:23 am
Website: http://www.crystalnetworks.org
Location: Dubai

Postby x2oxen » Wed Oct 15, 2008 9:04 pm

So which one from those is better one... Original one that was provided by Mr. Hamid or Altered one made by Mudassir??
Muhammad Usman

+92-321-6640501

Chemonics International

http://usmanpk.com
x2oxen
Major General
 
Posts: 1114
Joined: Wed Aug 22, 2007 3:17 pm
Website: http://usmanpk.com
WLM: x2oxen@hotmail.com
Yahoo Messenger: x2oxen
Location: Faisalabad


Return to “%s” Administration

Who is online

Users browsing this forum: No registered users and 2 guests

cron