RouterOS Script to Find iPhones

RouterOS Script to Find iPhones

 

This script will find devices in the DHCP Server leases list with a string in the device name. The purpose is to find iPhones so we can rate limit their upload, so as to not consume all our uplink bandwidth on slow connections by putting them on an address list. Feel free to use or customize.

      
/system script
add name=script1 owner=admin policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive source="/ip firew\
all address-list remove [find comment=\"dynamic iPhone catcher\" ]\r\
\n\r\
\n:foreach i in=[/ip dhcp-server lease find host-name~\"iPhone\"] do={\r\
\n/ip firewall address-list add address=[/ip dhcp-server lease get \$i addre\
ss] list=iPhones timeout=[/ip dhcp-server lease get \$i expires-after ] comm\
ent=\"dynamic iPhone catcher\" \r\
\n}\r\
\n\r\
\n:foreach i in=[/ip dhcp-server lease find host-name~\"iPad\"] do={\r\
\n/ip firewall address-list add address=[/ip dhcp-server lease get \$i addre\
ss] list=iPhones timeout=[/ip dhcp-server lease get \$i expires-after ] comm\
ent=\"dynamic iPhone catcher\" \r\
\n}"

  
 
    • Related Articles

    • Script to find and delete SIP connections in Mikrotik RouterOS

      This is handy when you only want to force SIP connections to re-establish: /ip firewall connection remove [/ip firewall connection find where connection-type=sip and assured=no] 
    • RouterOS Script to Set Master Port

        This script will set a series of ports to use one port as their master. Paste the script into a terminal or paste it to a notepad file named .rsc and import it. Edit the variables as described in the script and then run it. system script add ...
    • Script to add ports to a bridge

      # First, set port type i.e.: ether or sfp # This is for interfaces not named “ether” like SFP # Second set the bridge name # Then set ports in range form using SlavePortStart and SlavePortStop. Paste this into a terminal to create the script, change ...
    • MikroTik dual boot lets you choose between SwOS and RouterOS

      Beginning with MikroTik CRS3xx series due this summer, you will have the opportunity to choose which operating system you prefer to use, RouterOS or SwOS. If you prefer to have a simplified switch only OS with more switch specific features, use SwOS. ...
    • Basic Script to Configure a Blank MikroTik Router

        I have developed a script you can simply paste into the router and it will configure everything for you and get you started on the right track. /ip address add address=192.168.1.1/24 disabled=no interface=ether2 add address=192.168.2.1/24 ...