MyShaper

   


Myshapper (2004 Dominique Voillemot)
License : GPL

Well first excuse-me for my bad english, however I think you should undertand something !

This is an init script for RedHat or SYSV Linux to enable a shaper
on a ppp0 interface.
This shaper limit your upstream and allow you to keep a few bandwidth for mail,
messagers, irc, news (...) and brownsing your usuals Websites easily.
Useful if you have a server or if you are using a sharing client like Edonkey or
Napster.
Just put the ip of your messager, news and mail server (..) in /etc/myshaper.cfg
./myshaper start
and it's done !

You can easyly edit he files to match your configuration.
The most important is the routing table.
Exemple of routing tables for a ppp0 interface :

###
### BEFORE myshaper
###
----
[root@mylinux /]#
[root@mylinux /]# /sbin/route -n
Kernel routing table
Destination     Passerelle      Genmask         Indic Metric Ref
 Use Iface
80.14.174.1     0.0.0.0         255.255.255.255  UH    0      0        0 ppp0
127.0.0.0         0.0.0.0         255.0.0.0               U      0      0        0 lo
0.0.0.0             80.14.174.1     0.0.0.0              UG    0      0        0 ppp0
[root@mylinux /]# /sbin/ifconfig ppp0
ppp0      Lien encap:Protocole Point-à-Point
          inet adr:80.14.174.196  P-t-P:80.14.174.1  Masque:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:309775 errors:0 dropped:0 overruns:0 frame:0
          TX packets:298352 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 lg file transmission:3
          RX bytes:143591980 (136.9 Mb)  TX bytes:79967793 (76.2 Mb)

[root@mylinux /]#
----
###
### MYSHAPER will launch these commands (Replace my* by the ip) :
###
----
[root@mylinux /]#
[root@mylinux /]# /sbin/insmod shaper
[root@mylinux /]# /sbin/shapecfg attach shaper0 ppp0
[root@mylinux /]# /sbin/shapecfg speed shaper0 12000
[root@mylinux /]# /sbin/ifconfig shaper0 80.14.174.196 netmask 255.255.255.255 up
[root@mylinux /]#
#
# Shaper is up and ok
# The game is now to play with routing table and replace ppp0 by shaper0
#
[root@mylinux /]#
[root@mylinux /]# /sbin/route add 80.14.174.1 shaper0
[root@mylinux /]# /sbin/route del 80.14.174.1 ppp0
[root@mylinux /]# /sbin/route add default gw 80.14.174.1 shaper0
[root@mylinux /]# /sbin/route del default gw 80.14.174.1 ppp0
[root@mylinux /]#
#
# Adding now some ppp0 route for your needs
#
[root@mylinux /]#
[root@mylinux /]# /sbin/route add mymail ppp0
[root@mylinux /]# /sbin/route add mynews ppp0
[root@mylinux /]# /sbin/route add myirc ppp0
[root@mylinux /]# /sbin/route add mymsn ppp0
[root@mylinux /]#
----
###
### AFTER myshaper (No change to ppp0 interface)
###
----
[root@mylinux /]#
[root@mylinux /]# /sbin/ifconfig shaper0
shaper0   Lien encap:Protocole Point-à-Point
          inet adr:80.14.174.196  Masque:255.255.255.255
          UP RUNNING  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:177783 errors:0 dropped:0 overruns:0 carrier:0
          collisions:22665 lg file transmission:10
          RX bytes:0 (0.0 b)  TX bytes:42574550 (40.6 Mb)

[root@mylinux /]#
#
# Look in the last line "RX bytes:0 (0.0 b)"
# Remember shaper is only for upstream
#
[root@mylinux /]#
[root@mylinux /]# /sbin/route
Kernel routing Table
Destination     Passerelle      Genmask         Indic Metric Ref    Use Iface
80.14.174.1     0.0.0.0         255.255.255.255 UH    0      0        0 shaper0
127.0.0.0         0.0.0.0         255.0.0.0               U     0      0        0 lo
0.0.0.0             80.14.174.1 0.0.0.0                 UG    0      0        0 shaper0
mymail            0.0.0.0          255.255.255.255 UH    0      0        0 ppp0
mynews          0.0.0.0          255.255.255.255 UH    0      0        0 ppp0
myirc               0.0.0.0          255.255.255.255 UH    0      0        0 ppp0
mymsn            0.0.0.0          255.255.255.255 UH    0      0        0 ppp0
[root@mylinux /]#
[root@mylinux /]# /sbin/ifconfig shaper0
shaper0   Lien encap:Protocole Point-à-Point
          inet adr:80.14.174.196  Masque:255.255.255.255
          UP RUNNING  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:177783 errors:0 dropped:0 overruns:0 carrier:0
          collisions:22665 lg file transmission:10
          RX bytes:0 (0.0 b)  TX bytes:42574550 (40.6 Mb)

[root@mylinux /]#
----
###
###
###
Now you should be ready to do your own shaper !
Good Luck !
Dominique - 01/26/2004

Downloads :

Rpm package

Tar.gz package



     Dominique Voillemot  ©  2004