To control bandwith used by each client, I use simple queues.
For IPv4 clients, each queue is automatically created (upon lease bound), updated (upon IP address change), and removed (upon lease expiry) by /ip/dhcp-server lease-script.
For IPv6 clients, we don’t use DHCP, so I plan to periodically scan /ipv6/neighbor and create & remove queues based on its entries.
My proposed script is as follows, it should be run on a schedule:
# Clean up existing queues; this part is working fine
/queue simple
:foreach x in=[find comment~"IPv6 Client Queue"] do={
:local queuename [get $x name];
/queue simple remove $queuename;}
# Generate new queues, issues listed below
/ipv6 neighbor
:foreach y in=[find interface=bridge address!~"fe80:" status!="failed"] do={
:local addr [get $y address];
:local mac [get $y mac-address];
:local host [/ip arp get [find where mac-address=$mac] host-name]
:local queueName "Client - $mac";
/queue simple add name=$queueName target=($addr."/128") queue=client/client limit-at=1M/1M max-limit=10M/10M priority=8/8 parent="Gateway IPv6" comment="IPv6 Client Queue - $host";}
Issue list:
Apparently MikroTik doesn’t implement address!~“fe80:” (address that doesn’t start with fe80:).
Is there another way to implement this? I confirmed that address~“fe80:” works (address that starts with fe80:).
Issue solved on the next post.
Apparently MikroTik doesn’t implement status!=“failed”.
Is there another way to implement this? I confirmed that status=“failed” works.
Issue solved on the next post.
Even though WinBox displays host name in IP → ARP window, it is not provided on /ip/arp print. Therefore, /ip/arp get [find where mac-address=$mac] host-name fails.
I confirmed that /ip/arp get [find where mac-address=$mac] interface works. Are there other ways to lookup host name from a MAC address?
We can get host name from IPv4 DHCP leases using /ip/dhcp-server/lease get [find where active-mac-address=$mac] host-name. Therefore, this issue is also solved.
Writing that “Apparently MikroTik doesn’t understand ” is quite arrogant.
It’s not up to RouterOS (MikroTik is the company) to figure out what you wanted to do and try to guess the commands you wanted executed.
Apparently you doesn’t understand script syntax.
This work correctly on both v6.48.7 and v7.13.5
/ipv6 neighbor print where interface="bridge" and !(address~"^fe80:") and status!="failed"
This is totally bad style and wrong concept:
# Clean up existing queues; this part is working fine
/queue simple
:foreach x in=[find comment~"IPv6 Client Queue"] do={
:local queuename [get $x name];
/queue simple remove $queuename;}
Must be SIMPLY
/queue simple remove [find where comment~"IPv6 Client Queue"]
You're correct. My understanding of ROS script syntax and English language is low, therefore the apparent arrogance. I have edited the first post to reduce my apparent arrogance.
Thank you. This successfully addresses issue #1 and #2.
Thank you. Apparently both code did the same thing. However, I assume your code is more CPU-efficient.