Community discussions

MikroTik App
 
cchance
newbie
Topic Author
Posts: 39
Joined: Mon Dec 01, 2014 2:42 pm

Simple to PCQ by address list name?

Mon Jul 27, 2015 7:34 pm

Ok basically i've run into a problem with my planning to use MT as a BNG.

Plan was DHCP sends Opt-82 and Mac to radius, radius authenticate the opt-82 is an enabled customer sends back IP+Speeds for Simple queues for client.

This works fine, except for the fact if customer plugs in a switch to his DSL/GPON he then will get multiple ip's and each ip will get a clean simple queue of his speed (so if he was supposed to have 4mbit, he would have 4mbit per device on that switch behind the gpon opt-82)

So what I wanted to do was have Radius send back the ip with Option-82 as it's addresslist name, and simplequeue parameters

And then have a mikrotik script that goes through on the DHCP-Lease and converts the simple queue to a PCQ using the newly created addresslist (and generate the mangle/pcq if it wasnt previously created.

But holy crap am i lost in how to even start programming this... Radius returning the addresslist and simple queue is easy, but converting the SImple queue to PCQ "if needed" and performing cleanup when the lease expires, or logs in elsewhere, i just dont know how to handle.

Anyone got a few to help me out.
 
cchance
newbie
Topic Author
Posts: 39
Joined: Mon Dec 01, 2014 2:42 pm

Re: Simple to PCQ by address list name?

Mon Jul 27, 2015 9:51 pm

Well im getting closer, radius is returning
Mikrotik-Access-List = Opt82Agent-Opt82Circuit=UlKbps

This builds up the circuits properly, but i'll need to have a lot of checks, like when dhcp expires a lease to remove the pcq/mangle rules IF the addresslist is empty, does dhcp lease script, run when leases expire also or just when they are created?

Anything i'm missing? (really wish their was an easier way to cleanup picks like to be able to do pick $opt82 [:find $opt72 "="] + 1 to get rid of the = in the result instead of having to run another pick starting at char 1, unless of course i missed it as i said im new to mikrotik scriptiong)


:global leaseBound
:global leaseServerName
:global leaseActMAC
:global leaseActIP

:local opt82 [/ip firewall address-list get value-name=list [find address=$leaseActIP]];

:local upload [:pick $opt82 [:find $opt82 "="] [:find $opt82 "/"]]; local upload [:pick $upload 1 [len $upload]];
:local download [:pick $opt82 [:find $opt82 "/"] [len $opt82]]; local download [:pick $download 1 [len $download]];

[/queue type add name="dl-$opt82" kind=pcq pcq-rate=$download pcq-classifier=dst-address];
[/queue type add name="ul-$opt82" kind=pcq pcq-rate=$upload pcq-classifier=src-address];

[/ip firewall mangle add action=mark-packet chain=prerouting in-interface=vCUSTOMERS new-packet-mark="ul-$opt82" src-address-list="$opt82"];
[/ip firewall mangle add action=mark-packet chain=postrouting out-interface=vCUSTOMERS new-packet-mark="dl-$opt82" dst-address-list="$opt82"];
[/queue tree add parent=global-in queue="dl-$opt82" packet-mark="dl-$opt82"];
[/queue tree add parent=global-out queue="ul-$opt82" packet-mark="ul-$opt82"];
 
cchance
newbie
Topic Author
Posts: 39
Joined: Mon Dec 01, 2014 2:42 pm

Re: Simple to PCQ by address list name?

Mon Jul 27, 2015 11:06 pm

And i hit my first roadblock, the lease script isn't re-running when the lease is renewed? I see it get updated values from radius, the dhcp gets sent to the client, but the script doesn't run again?!?!?!?!