You can write in your RADIUS configuration something like:
Код:
mpd-table += "1=10.0.0.1",
mpd-table += "1=10.0.0.15",
mpd-pipe += "1=bw 10Kbyte/s",
mpd-pipe += "5=bw 20Kbyte/s",
mpd-rule += "1=pipe %p1 all from any to table\\(%t1\\) in",
mpd-rule += "2=pipe %p5 all from table\\(%t1\\) to any out",
mpd-rule += "100=allow all from any to any",
When mpd receives these parameters it will call ipfw(8) to create firewall rules, pipes and queues with unique numbers starting from 10000 (configurable via 'set global start...'). %rX, %pX, %qX, %tX macroses will be expanded within mpd-rule and mpd-queue. To the end of each rule will be added "via ngX" to make the rule apply only to that client's networking interface.
As a result of this example we would get these commands executed:
Код:
ipfw table 32 add 10.0.0.1
ipfw table 32 add 10.0.0.15
ipfw pipe 10000 config bw 10Kbyte/s
ipfw pipe 10001 config bw 20Kbyte/s
ipfw add 10000 pipe 10000 all from any to table\(32\) in via ng0
ipfw add 10001 pipe 10001 all from table\(32\) to any out via ng0
ipfw add 10002 allow all from any to any via ng0
When the link goes down, all created rules will be removed.
Note: As soon as mpd executes ipfw commands using shell, shell's special characters like "(" and ")" must be slashed.