0

I found tc, which allows you to filter by ip, port etc. and then limit rates. But I was wondering if there was anything that could filter by application or limit rate given another process' socket ..

Thanks!

ok seems like

I can use lsof -iTCP and ipfw pipes ... wonder how efficient that is ..

lsof -iTCP: http://danielmiessler.com/study/lsof/

ipfw: http://www.macgeekery.com/hacks/software/traffic_shaping_in_mac_os_x

ipfw in C: http://psb.sbras.ru/cgi-bin/www/unix_help/unix-man?ipfw+4

with rate limiting (dummynet): http://www.opensource.apple.com/source/network_cmds/network_cmds-115.2/ipfw.tproj/ipfw.c

Lavanya
  • 103
  • 3

1 Answers1

2

Netfilter (iptables) has the owner (and also a socket, if you wish to use that) module. With it you can apply standard firewall rules if user id or group id matches, and optionally match if the packet is associated with a socket.

iptables -t mangle -A PREROUTING -m owner -u some_user --socket-exists -j MARK --set-mark 100

Then just use tc in a way it catches mark 100:

tc filter add dev eth0 parent ffff: protocol ip prio 10 u32 match mark 100 ...

This was just my mindflow and I have no idea if this works, but give it a try. :)

Janne Pikkarainen
  • 31,852
  • 4
  • 58
  • 81