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:
Code: Select all
# 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.
Thanks in advance.