ROS2.96½Å±¾Ïê½â
ËÄÖÖ±äÁ¿ global - ¶¨ÒåÈ«¾Ö±äÁ¿, ¿ÉÒÔÒªËùÓеĽű¾Öе÷Óù²Ïí local - ¶¨Òå±¾µØ±äÁ¿£¬Ö»ÄÜÔÚÆäËùÒªµÄ½Å±¾Ïµ÷Ó㬲»Äܱ»ÆäËü½Å±¾¹²Ïí loop index variables - ¶¨ÒåÔÚfor»òforeachÀïµÄË÷ÒýºÅ±äÁ¿ monitor variables - ¼àÊÓ±äÁ¿
ROSËãÊõ²Ù×÷ - ¸ººÅ£»Ïà¼õ¡£ ! Âß¼·Ç¡£ / Ïà³ý¡£ . Á¬½Ó¡£Á½¸ö·û´®µÄÁ¬½Ó£¬Ìí¼ÓÔªËØµ½Áбí ^ Òì»ò(XOR) ~ È¡·´ * ÏàÊ£ & Óë(AND) && Âß¼Óë + Ïà¼Ó < СÓÚ << Ïò×óÎ»ÒÆ <= СÓÚµÈÓÚ > ´óÓÚ >= ´óÓÚµÈÓÚ >> ÏòÓÒÎ»ÒÆ | »ò || Âß¼»ò
ROS˵Ã÷ÊéÀïµÄÀý×Ó£º
¼ÆËã˳Ðò [admin@MikroTik]> :put (10+1-6*2=11-12=2+(-3)=-1) false [admin@MikroTik]> :put (10+1-6*2=11-12=(2+(-3)=-1)) true
Âß¼·Ç [admin@MikroTik]> :put (!true) false [admin@MikroTik]> :put (!(2>3)) true
Êýλȡ·´ [admin@MikroTik]> :put (~255.255.0.0) 0.0.255.255
¼Ó·¨ [admin@MikroTik]> :put (3ms + 5s) 00:00:05.003 [admin@MikroTik]> :put (10.0.0.15 + 0.0.10.0) cannot add ip address to ip address [admin@MikroTik]> :put (10.0.0.15 + 10) 10.0.0.25
¼õ·¨ [admin@MikroTik]> :put (15 - 10) 5 [admin@MikroTik]> :put (10.0.0.15 - 10.0.0.3) 12 [admin@MikroTik]> :put (10.0.0.15 - 12) 10.0.0.3 [admin@MikroTik]> :put (15h - 2s) 14:59:58
³Ë·¨ [admin@MikroTik]> :put (12s * 4) 00:00:48 [admin@MikroTik]> :put (-5 * -2) 10
³ý·¨ [admin@MikroTik]> :put (10s / 3) 00:00:03.333 [admin@MikroTik]> :put (5 / 2) 2 [admin@MikroTik]> :put (0:0.10 / 3) 00:00:02
±È½Ï [admin@MikroTik]> :put (10.0.2.3<=2.0.3.10) false [admin@MikroTik]> :put (100000s>27h) true [admin@MikroTik]> :put (60s,1d!=1m,3600s) true [admin@MikroTik]> :put (bridge=routing) false [admin@MikroTik]> :put (yes=false) false [admin@MikroTik]> :put (true=aye) false
Âß¼Óë AND, Âß¼»ò OR [admin@MikroTik]> :put ((yes && yes) || (yes && no)) true [admin@MikroTik]> :put ((no || no) && (no || yes)) false
ÊýλÓëAND, »òOR, Òì»òXOR [admin@MikroTik]> :put (10.16.0.134 & ~255.255.255.0) 0.0.0.134
Î»ÒÆ²Ù×÷ [admin@MikroTik]> :put (~((0.0.0.1 << 7) - 1)) 255.255.255.128
Á¬½Ó²Ù×÷ [admin@MikroTik]> :put (1 . 3) 13 [admin@MikroTik]> :put (1,2 . 3) 1,2,3 [admin@MikroTik]> :put (1 . 3,4) 13,4 [admin@MikroTik]> :put (1,2 . 3,4) 1,2,3,4 [admin@MikroTik]> :put ((1 . 3) + 1) 14 [admin@MikroTik]> :set a "It's " [admin@MikroTik]> :put ($a . OK) It's OK
ROS½Å±¾±£Áô×Ö beep execute global list pick time toip typeof delay find if local put toarray tonum while do for led log resolve tobool tostr environment foreach len nothing set toid totime
:beep length=2s frequency=10000 ²úÉú2Ãë10kHzµÄÒôƵ lengthȱʡֵΪ100ms frequencyȱʡֵΪ1000Hz
:set a "/int dis lan\n/int dis wan" :execute $a Ö´ÐжàÌõÃüÁî,Àý×ÓÀïÖ´ÐÐÁËÁ½ÌõÃüÁî¡£\nÊÇ»»ÐÐ
:global ¶¨ÒåÈ«¾Ö±äÁ¿
:list interface ÏÔʾÏà¹ØÃüÁî¡£ÏÔʾµ±Ç°Ä¿Â¼¼°×ÓĿ¼ÏÂÓйØinterfaceµÄÃüÁî
:pick È¡×Ö·û´®»òÊý×éµÄijһ¶Ï¡£×Ö·û´®£¨Êý×飩µÄµÚÒ»¸öΪ0¡£ [admin@MikroTik]>:put [:pick "I love you" 2 6] love
:time Ö´ÐÐÃüÁîËùÐèµÄʱ¼ä [admin@MikroTik]> :put [:time [:resole www.sina.com.cn> 00:00:00.006 Ö´ÐнâÎöwww.sina.com.cnÕâ¸öÓòÃûËùÐèµÄʱ¼ä
toip toarray tonum tobool tostr toid totime ת»»ÖµÀàÐÍ
:delay 3 ÑÓʱ3Ã룬ȱʡΪ1Ãë
:find ²éÕÒ×Ö·û´®»òÊý×éÖеÚÒ»¸ö³öÏÖ²éÕÒÄÚÈݵÄλÖà [admin@MikroTik]>:put [:find abcdcba cd] 2 [admin@MikroTik]>:put [:find "1,2,3,4,3,2,1" 2] 1
:put Êä³öµ½ÆÁÄ»ÉÏ£¬ÉÏÃæ¾ÍºÜ¶àÀý×ÓÁË¡£
:if Ìõ¼þÑ¡Ôñ [admin@MikroTik]>:if(1<2) do={:put true} true Èç¹ûÌõ¼þÎªÕæ£¬Ö´ÐÐdo={}ÀïÃæµÄÃüÁî [admin@MikroTik]>:if(1>2) do={:put true} else={:put flase} flase Èç¹ûÌõ¼þÎªÕæ£¬Ö´ÐÐdo={}ÀïÃæµÄÃüÁ·ñÔòÖ´ÐÐelse={}ÀïÓÐÃüÁî
:local ¶¨Òå±¾µØ±äÁ¿
:while Ìõ¼þÎªÕæÊ±Ñ»·Ö´ÐÐdo={}ÀïµÄ½Å±¾ÃüÁî [admin@MikroTik]>:set i 0;:while($i<5) do={:put $i;:set i ($i+1)} 0 1 2 3 4 5
:for Ñ»·Ö´ÐÐdo={}ÀïµÄ½Å±¾ÃüÁî :for i from=1 to=100 step=30 do={:put $i} 1 31 61 91
:foreach ÔÚ¼¯ºÏ£¨Êý×飩ÀïÑ»·Ö´ÐÐdo={}ÀïµÄ½Å±¾ÃüÁî :foreach i in=[/interface find type=ether] do={:put [/interface get $i name]} ether1 ether2 ether3 ether4 ÔÚ[/interface find type=ether]µÄ¼¯ºÏ£¨ÀàÐÍΪetherµÄinterface ID£©Ñ»·Êä³ö
interfaceµÄÃû³Æ¡£ÎÒÕâʱÓÐËÄÕÅÍø¿¨
:log ÈÕÖ¾ÀàÐÍ ÈÕÖ¾ÄÚÈÝ Ð´Îı¾µ½ÈÕÖ¾£¨script log£© ÀàÐÍÔÚ/system loggingÀï¿ÉÒÔÕÒµ½ :log info "ϵͳÐÅÏ¢" µ½LOGÀï²é²éÔËÐнá¹û°É
:resolve ½âÎöÓòÃûµÄIPµØÖ· [admin@MikroTik] > :put [:resolve www.sina.com.cn] 61.172.201.240
:environment print ÏÔʾËùÓбäÁ¿¼°ÆäÖµ
:len ×Ö·û´®»òÊý×éµÄ³¤¶È [admin@MikroTik] > :put [:len hello] 5 [admin@MikroTik] > :put [:len "1,2,23,65,54,6"] 6
:nothing ¿ÕÖµ¡£nothing²»µÈ0,²»µÈÓÚ¿Õ×Ö·û"" :find abc aµÄ½á¹ûÊÇ0 :find abc dµÄ½á¹ûÊÇnothing
:set ¸³Öµ [admin@MikroTik] > :set a test ½«abc×Ö·û¸³¸ø±äÁ¿a [admin@MikroTik] > :put $a test [admin@MikroTik] > :put a a ÒýÓñäÁ¿µÄÖµÒªÔÚ±äÁ¿Ç°Ãæ¼Ó$
³£Óýű¾ÊÕ¼¯
ɾ³ýËùÓÐÁ¬½Ó / ip firewall connection {:foreach r in=[find] do={remove $r}}
disable·À»ðǽ¹æÔò :foreach i in=[/ip firewall filter find action=drop ] do=[/ip firewall filter disable $i]
¼õÇásyn¹¥»÷ firewall connection tracking syn sendtime ÉèÖóÉ50 rectime ÉèÖóÉ30
# RouterOS 2.96 # ÕâÊÇÉñÏÉÊÔдµÄÒ»¸ö¶Ô192.168.0.0Õâ¸öÍø¶ÎµÄ # ÿ¸öIP¼ÓÒ»¸ösimple queueµÄ½Å±¾ # Íø¹Ø100¾Í²»ÏÞÖÆÁË
# ×¢Ò⣺À©Õ¹ÃûÓ¦¸ÄΪ.rsc
:foreach i in [/queue simple find] do {:put (deleting . ... . [/queue simple get $i name]); /queue simple remove $i;}
:for i from 1 to 254 do { :if ($i!=100) do {/queue simple add name=(queue . $i) limit-at=128000/128000 burst-threshold=384000/192000 max-limit=512000/256000 burst-limit=2000000/512000 burst-time=16s/8s dst-address=(192.168.0. . $i); :put (192.168.0. . $i . ... . added)} }
¶¨Ê±ÖØÆð /system scheduler add name=reboot interval=24h start-time=11:59:00 on-event={/system reboot} disabled=no
¸Ä±äĬÈÏÍø¹Ø /ip route set [/ip route find dst-address=0.0.0.0/0] gateway=xxx.xxx.xxx.xxx
Simple Queues ÏÞËÙ :for i from=1 to=75 do={/queue simple add target-address=(192.168.1. . $i . "/32") max-limit=56000}
ɾ³ýËùÓÐSimple Queues /queue simple remove [find]
ARP°ó¶¨(¾²Ì¬ARP) :foreach i in=[/ip arp find dynamic=yes ] do={/ip arp add copy-from=$i
for aaa from 1 to 254 do={/ip firewall filter add chain=forward src-address=(192.168.0. . $aaa) protocol=tcp connection-limit=50,32 action=drop}
ÆäÖеÄ1 to 254 ÊÇ192.168.0.1-192.168.0.254È«Íø¶Î£¬Çëɾ³ý´úÀí·þÎñÆ÷IPµØÖ·ºÍ¾ÖÓòÍøÖ÷»úIPµØÖ·¡£
connection-limit=50ÊÇÏß³ÌÊýÕâÀïΪ50¡£
ʹÓ㺠WinBox-System-Scripts-£« Name(½Å±¾Ãû³Ì) Source(½Å±¾)
°ÑÒÔÉϽű¾¸´ÖƵ½Source ÏîÄ¿ÀïÃæ£¬µã»÷ OK-Ñ¡ÔñÒªÔËÐеĽű¾-Run Script
ʵµ±Íø¿¨»ùÓÚ°²×°ºóĬÈϵÄenabledʱ£¬»á×Ô¶¯¼ÓÈëÓërosÏàÁ¬½ÓµÄÍø¶ÎµÄmacµÄµØÖ·¶ÔÓ¦Êý¾Ý µÄ¡£ÆôÓÃÁËREPLY-ONºó·ÇÊÖ¶¯¼ÓÈëµÄ¾Í±»×èµ²ÓÚÁбíÖ®ÍâÁË¡£·½·¨ÊÇÊÖ¹¤¼ÓÈë»òÊÇÔÚÖÕ¶Ëģʽ¼Ócopy»òÊÇÕûÀíºÃµÄÊý¾Ý ÔÚÕ³Ìù¼ÓÈ룬»òÊÇÀûÓÃÔÀ´µÄµ¼³öÊý¾Ý£¬×÷µ¼Èë´¦Àí¡£Ã»¼Ó¹ýÒ»´Î¾Í¿ÉÒÔÓýű¾ºÍÖ¸ÁîʵÏÖÅúÁ¿¼ÓÈ룬ÀàËÆÓÚÅú´¦ÀíÖ¸Áî¡£ --------------------------------------------------------------------------------------------------- ×Ô¶¯É¨Ãè¼ÓÈëip-arpÖ¸Á ·½Ê½A: ±ê×¼¸ñʽ
:foreach i in=[/ip arp find dynamic=yes ] do=[/ip arp add copy-from=$i]
·½Ê½B£º :foreach i in [/ip arp find dynamic yes ] do={/ip arp add copy-from $i} ------------------------------------------------------------------------------------------------------------
:set i 27;:while($i<51) do={/ip arp add 192.168.0.$i int lan mac-add 00ffffffffff} ×Ô¶¯É¾³ýÖ¸Á ·½Ê½A£º :foreach i in [/ip arp find] do={/ip arp remove $i}
·½Ê½B£º±ê×¼¸ñʽ :foreach i in= [/ip arp find] do=[/ip arp remove $i]
|