Bandwidth rate limiting with FreeBSD ipfw

Sometimes it’s desirable to be able to limit bandwidth on a connection, be it on a specific port or maybe for the entire link.
If you are using FreeBSD you can use ipfw and dummynet to enable rate limiting on your link.

You need to have IPFIREWALL and DUMMYNET enabled in the kernel. If they are not already you need to recompile your kernel.

First you need to setup a pipe:

ipfw pipe 1 config bw 512Kbit

This creates a pipe, with throughput limited to 512 Kbps.

Let’s say you want to put a limit on your outgoing http traffic (port 80) . You would add this rule to your firewall, pushing the TCP packets through the pipe you just created.

ipfw add 10 pipe 1 tcp from me 80 to any

You can list pipes with the command ipfw pipe show.

References:
ipfw manpage
dummynet manpage

Tags: , , , , , , , , , , ,

Leave a Comment

Couldn't find your convert utility. Check that you have ImageMagick installed.