Nov 04 |
Advanced OS X users know that Darwin comes with ipfw, which can be used to set up a custom firewall. IPFW’s flexibility, very targeted bandwidth limiting rules can be made in only a few lines. This same service however can be used to also limit bandwidth on specific ports.
The following ipfw rules will limit connections from Mac to ISP’s mail server to 100K per second only for outgoing smtp connections:
sudo ipfw pipe 1 config bw 100Kbit/s sudo ipfw pipe 1 tcp from me to smtp.west.cox.net 25
Obviously, the rate can be tailored to anything you like, and the rule is specific enough not to get in the way of any other connections going on.
to remove the pipe from the port
sudo ipfw delete 1
Another example could be for webdevelopers
You should see how long it takes modern sites to load on 56k…
Create a pipe that only allows up to 15KB/s
sudo ipfw pipe 1 config bw 15KByte/s
Attach that pipe to the outgoing traffic on port 80
sudo ipfw add 1 pipe 1 src-port 80
Delete the pipe when finished
sudo ipfw delete 1



September 15th, 2011 at 11:05 PM
A question… What is the meaning of the 25 at the end of the second command?
September 29th, 2011 at 12:08 AM
@Ignacio: that ’25′ is the TCP port number, in this case for an SMTP server.
@OP:
There is a mistake in this line:
sudo ipfw pipe 1 tcp from me to smtp.west.cox.net 25
it should be
sudo ipfw add 1 pipe 1 tcp from me to smtp.west.cox.net 25
(i.e. you forgot the “add ” in the example)
I’ve been using this throttling for years, but for some unexplained reason this throttling has stopped working for me in recent months. I am running Snow Leopard 10.6.8 presently, I think one of the updates in the past months broke this for me…
September 29th, 2011 at 2:18 AM
Also, “ipfw delete 1″ does not delete the pipe, it deletes rule/s #1. To delete the pipe numbered 1, you need to do:
ipfw pipe 1 delete
To list the rules:
ipfw list
To list the pipes:
ipfw pipe list