Re: Shaping on Aliases

Sketch (
Sun, 19 Dec 1999 22:26:05 -0500 (EST)

On Mon, 22 Nov 1999, Ajit Anvekar wrote:

Sorry for the rather late reply, I don't read this list much...

> I am interested in finding out if Linux's shaping features have been
> used with IP Aliasing. One of the documents on the LWN refers to this
> case. If anybody has had any experience in this or if there is some
> Documentation, please forward it to me.

The 2.x traffic shaper module can only be attached to a physical device,
however, you can route multiple aliased IP's through it.

A few things to note:

* As stated by the documentation, the traffic shaper module only "shapes"
OUTGOING traffic on a device (though you can cheat on that).

* You can route as many IP's through it as you want, but they will all
share the same bandwidth.

We have a customer at work who buys some of our bandwidth, and I have a
linux box set up as a router to limit their bandwidth usage.

Since all traffic to their network either passes out the physical
interface to the real world, or out the aliased IP to their subnet, it
gets shaped in both directions.

x.x.148.0 - our network (.148.1 is our router, .148.222 is the linux box)
x.x.222.0 - customer's network (.222.1 is the aliased IP of the linux box)

Here's the script I run on the machine to set up the modules and routing:

# rc.shaper
# Turn on IP forwarding and delete all old ethernet routes
echo 1 > /proc/sys/net/ipv4/ip_forwarding
/sbin/route del x.x.148.0 eth0

# Configure inside IP alias
/sbin/modprobe ip_alias
/sbin/ifconfig eth0:0 x.x.222.1 netmask broadcast x.x.222.255 up

# Configure shaper device
/sbin/modprobe shaper
/sbin/shapecfg attach shaper0 eth0
/sbin/shapecfg speed shaper0 256000
/sbin/ifconfig shaper0 x.x.148.222 netmask broadcast x.x.148.255 up

# Shape outgoing traffic
/sbin/route add -net x.x.148.0 dev shaper0

# Shape incoming traffic
/sbin/route add -net x.x.222.0 dev shaper0

# Add default route through the shaper
/sbin/route add default gw x.x.148.1

# End

Of course, these days you can probably do this much more easily with one
of the new QoS routing schedulers, but documentation on them was pretty
sparse last time I looked.


- To unsubscribe from this list: send the line "unsubscribe linux-net" in the body of a message to