Tech Journal Back to Tech Journal

How can I limit the upstream traffic to a certain network?

Well, the easiest way to do it is to use the shaper module. I think you need a kernel version 2.0.36 and above to use it, though. In my case, I wanted to limit the upstream for the network 62.0.x.x which was going out through my ppp0. Using shaper on ppp0 is so incredibly not-recommended that you should never do it. (unless you have to, of course). I simply used:

### load and configure the shaper module
$ /sbin/modprobe shaper
$ /sbin/shapecfg attach shaper0 ppp0
$ /sbin/shapecfg speed shaper0 64000

### define a useful shaper0 device and its route
$ /sbin/ifconfig shaper0 212.143.34.1 netmask 255.255.255.255 up
$ /sbin/route add -net 62.0.0.0 netmask 255.255.0.0 dev shaper0

Which loaded the shaper module, attached it to ppp0, and set the max speed to 64000 baud (approx. 64000 bits/second). Then it created the shaper0 interface, with the same network config as the ppp0 device, and forced all traffic for the 62.0.x.x network through it.

To unload the shaper module, first take down the shaper0 interface, and only then unload the module:

$ /sbin/route del -net 62.0.0.0 netmask 255.255.0.0 dev shaper0
$ /sbin/ifconfig shaper0 212.143.34.1 netmask 255.255.255.255 down
$ /sbin/rmmod shaper

Though this tends to cause kernel errors when I didn't do the "route" thingy.

I suppose that if you wanted to limit all traffic through ppp0, you could set up a default route instead of the one I used, but I have no idea why you'd ever want to limit all traffic through ppp0. It's a special case. (I can understand why you'd want to limit traffic to a LAN device like eth0, but there's not issue of shared bandwidth in a PPP link).

Last updated on 2001-11-14 14:00:00 -0700, by Shalom Craimer

Back to Tech Journal