MacOS – How to limit bandwidth for a specific port/app in OS X 10.10 Yosemite

macostcp

I am running OS X 10.10 Yosemite, and I am looking for a way to limit upload bandwidth specifically on TCP port 8333, so I can run Bitcoin Core to contribute outgoing bandwidth without completely saturating my connection.

Here is a list of utilities I have looked into:

  • ipfw – This has been deprecated since OS X 10.7, and has been removed in OSX 10.10. Unfortunately this also means that any ipfw GUIs are out too (Waterroof, Speedlimit, Noobproof, etc).

  • Network Link Conditioner – This allows bandwidth limiting on Yosemite, but only on a system-wide level. I’m looking for a solution that will limit bandwidth only on a specific port, or only for a specific app, so my entire system won’t be affected by the limit.

  • pfctl – This is the new tool that replaces ipfw in Yosemite, but there is a lot less help available online, especially on limiting port/application bandwidth.

  • dnctl – There is almost no documentation available for this online, but it seems like it may be able to do the job if configured properly. It has been mentioned before in this Stack Overflow question, but the answer doesn't provide any examples on how to use/configure dnctl to limit bandwidth.

In short, I am looking for a way to limit bandwidth of a specific application/port on OS X 10.10 Yosemite. Does anything like this exist? And if so, how can I use it to limit outgoing traffic for a specific app, or on TCP port 8333?


Here is what I've tried with pfctl and dnctl:

Maximillians-MacBook:~ Max$ sudo pfctl -E
Password:
No ALTQ support in kernel
ALTQ related functions disabled
pf enabled
Token : 1626248500898813477
Maximillians-MacBook:~ Max$ (cat /etc/pf.conf && echo "dummynet-anchor \"customRule\"" && echo "anchor \"customRule\"") | sudo pfctl -f -
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.

No ALTQ support in kernel
ALTQ related functions disabled
Maximillians-MacBook:~ Max$ echo "dummynet in quick proto tcp from any to any port 8333 pipe 1" | sudo pfctl -a customRule -f -
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset added by the system at startup.
See /etc/pf.conf for further details.

No ALTQ support in kernel
ALTQ related functions disabled
Maximillians-MacBook:~ Max$ sudo dnctl pipe 1 config bw 10Kbit/s
Maximillians-MacBook:~ Max$ 

Unfortunately I'm still getting over 1Mbit/s chugging through my connection on port 8333.

Best Answer

For port 8333:

Create the anchor for pf to use:

(cat /etc/pf.conf && echo "dummynet-anchor \"customRule\"" && echo "anchor \"customRule\"") | sudo pfctl -f -

Create the PIPE to send the desired port to your dummynet anchor:

echo "dummynet in quick proto tcp from any to any port 8333 pipe 1" | sudo pfctl -a customRule -f -

Then set the desired speed for the pipe you created: (E.X: limit to 10mb/s)

sudo dnctl pipe 1 config bw 10Mbit/s

http://mop.koeln/blog/2015/06/01/Limiting-bandwidth-on-Mac-OS-X-yosemite/

I have been using a app called Murus, It claims to do this and much more but I have yet to get it to work on the free version for port throttling. Very powerful otherwise of a gui app.