Mikrotik Script Auto Queues DHCP

Script Auto Queues DHCP

เครื่องที่ได้รับ DHCP จะได้ความเร็วที่ 5M/5M ทุกเครื่อง

ใส่srcipt นี้เข้าไปที่ IP — > DHCP Server

:local queueName "Client- $leaseActMAC";
:if ($leaseBound = "1") do={
/queue simple add name=$queueName target=($leaseActIP . "/32") limit-at=5120k/5120k max-limit=5120k/5120k comment=[/ip dhcp-server lease get [find where active-mac-address=$leaseActMAC && active-address=$leaseActIP] host-name];
} else={
/queue simple remove $queueName
}

 

Scritpt update DynDNS สำหรับ Mikrotik V.6

บันทึกไว้กันลืม เวลาจะใช้สอยก็หยิบจับเอามาใช้ได้สะดวก

Script

:global ddnsuser "myuser"
:global ddnspass "mypassword"
:global theinterface "myinterfacename"
:global ddnshost myname.dyndns.org
:global ipddns [:resolve $ddnshost];
:global ipfresh [ /ip address get [/ip address find interface=$theinterface ] address ]
:if ([ :typeof $ipfresh ] = nil ) do={
:log info ("DynDNS: No ip address on $theinterface .")
} else={
:for i from=( [:len $ipfresh] - 1) to=0 do={
:if ( [:pick $ipfresh $i] = "/") do={
:set ipfresh [:pick $ipfresh 0 $i];
}
}

:if ($ipddns != $ipfresh) do={
:log info ("DynDNS: IP-DynDNS = $ipddns")
:log info ("DynDNS: IP-Fresh = $ipfresh")
:log info "DynDNS: Update IP needed, Sending UPDATE...!"
:global str "/nic/update\?hostname=$ddnshost&myip=$ipfresh&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
/tool fetch address=members.dyndns.org src-path=$str mode=http user=$ddnsuser \
password=$ddnspass dst-path=("/DynDNS.".$ddnshost)
:delay 1
:global str [/file find name="DynDNS.$ddnshost"];
/file remove $str
:global ipddns $ipfresh
:log info "DynDNS: IP updated to $ipfresh!"
} else={
:log info "DynDNS: dont need changes";
}
}