#send common msg to api :local i [/system identity get name] :local u [/system resource get uptime] :local c [/system resource get cpu-load] :local f [/system resource get free-memory] :local rcnt [/radius print count-only where disabled=no] :local wst foreach i in=[/interface find type=ether] do={ :local en [/interface get $i name]; :local rxa [/interface get $i rx-byte]; :local txa [/interface get $i tx-byte]; :delay 1 :local rxb [/interface get $i rx-byte]; :local txb [/interface get $i tx-byte]; :local rx ($rxb-$rxa) :local tx ($txb-$txa) :set wst "$wst,$en-$rx-$tx" } :local pa [/interface pppoe-client print count-only] :local pd [/interface pppoe-client print count-only where disabled] :local pr [/interface pppoe-client print count-only where running] :local sa [/ppp secret print count-only] :local sd [/ppp secret print count-only where disabled] :local a [/ppp active print count-only] /ip address :local sumadds 0 :local wanaddrs :foreach i in=[find disabled=no dynamic=yes interface~"ppp|adsl"] do={ :local wipaddr [get $i address] :local iphx [:pick $wipaddr 0 [:find $wipaddr "."]] :if ($sumadds<3 and $iphx!="100" and $iphx!="10" and $iphx!="192" and $iphx!="172") do={ :local wipaddr [get $i address] :set wipaddr [:pick $wipaddr 0 ([:len $wipaddr] -3)] :set wanaddrs "$wanaddrs,$wipaddr" :set sumadds ($sumadds + 1) } } /tool fetch url="http://log.371it.net/rosmsgpush?u=$u&c=$c&f=$f&wst=$wst&pa=$pa&pd=$pd&pr=$pr&sa=$sa&sd=$sd&a=$a&i=$i&rc=$rcnt&wips=$wanaddrs" mode=http keep-result=no;
UP-scripts脚本
:local x 0 :local addr ($"local-address") :local int [/int get $interface name] :local sn [:pick $int 9 13 ] :local nextint ("pppoe-out".($sn+1)) /log war $nextint :local ipc [ ($addr & 255.255.255.0)] :local ipd [:pick $ipc 0 [:find $ipc ".0"]] :log error ($int."的IP段为".$ipd) :foreach i in=[/ip address find dynamic=yes && interface!=$int && interface~"pppoe-out"] do={ :local oipa [/ip addr get $i address] :local oipb [:pick $oipa 0 [:find $oipa "/"]] :local oipc [ ($oipb & 255.255.255.0)] :local oipd [:pick $oipc 0 [:find $oipc ".0"]] :if ($ipd = $oipd) do={:set $x ($x+1)} } /log error ("当前IP c段重复次数".$x) :if ($x > 35) do={ :delay $x /int pppoe-c disable $int :delay 5 /int pppoe-c enable $int} else={ :if ([/in pppoe-c get $nextint disabled] = true) do={ /in pppoe-c enable $nextint}} :local rosname [/system identity get name] /log war ($rosname.
DNSPOD脚本
#dnspod PPPoE :local pppoe "pppoe-out245" #填写域名,和主机名 :local token "107874,8db57498abcaaaa6726d4614cfe06c81" :local domain "pkjip.cn" :local record "hanq103" #以下不需要修改 /ip dns cache flush :local domainname ($record . "." . $domain) :log info ("要解析的域名为" . $domainname) :local iponint ([:resolve $domainname]) :log info ("解析得到ip为:" . $iponint) :local ipinlocal [/ip address get [/ip address find interface=$pppoe] address] :set ipinlocal [:pick $ipinlocal 0 ([len $ipinlocal] -3)] :log info ("本地出口ip为:" . $ipinlocal) :if ($iponint = $ipinlocal) do={ :log info ("ip一致无需解析") } :if ($iponint != $ipinlocal) do={ :local url "http://www.hatrace.cn/d.php?token=$token&ip=$ipinlocal&domain=$domain&record=$record" /log error $url /tool fetch url=$url mode=http keep-result=no :set iponint $ipinlocal /log war "ddns提交成功" }
批量换MAC
:local macadd "D0:37:45,60:3A:7C,54:A7:03,B0:BE:76,34:E8:94,AC:84:C6,94:D9:B3,B0:95:8E,C0:25:E9,24:69:68,80:89:17,00:27:19,40:16:9F,F4:EC:38,14:CF:92,20:DC:E6,14:CC:20,90:F6:52,54:C8:0F,E4:D3:32,C4:E9:84,28:2C:B2,E8:DE:27,BC:D1:77,D8:07:B6,64:6E:97,98:DA:C4,CC:08:FB,D4:6E:0E,00:14:78,30:FC:68,DC:00:77,54:E6:FC,74:EA:3A,F8:1A:67,EC:17:2F,00:19:E0,00:25:86,14:E6:E4,50:C7:BF,A8:57:4E,E8:94:F6,1C:FA:68,C0:4A:00,50:D4:F7,9C:A6:15,D0:76:E7,78:44:FD,0C:4B:54,7C:8B:CA,B0:4E:26,C0:E4:2D,8C:A6:DF,84:16:F9,18:D6:C7,08:1F:71,40:3F:8C,C0:61:18,6C:E8:73,C4:6E:1F,50:FA:84,44:B3:2D,88:25:93,D8:5D:4C,A0:F3:C1,00:1D:0F,00:23:CD,D8:15:0D,CC:34:29,68:FF:7B,80:8F:1D,0C:80:63,48:0E:EC,50:3E:AA,48:7D:2E,B8:F8:83,DC:FE:18,70:4F:57,28:EE:52,30:B4:9E,18:A6:F7,1C:44:19,F8:D1:11,B0:48:7A,94:0C:6D,64:70:02,10:FE:ED,64:56:01,EC:26:CA,14:75:90,50:BD:5F,3C:46:D8,D0:C7:C0,D4:01:6D,14:86:92,A8:15:4D,0C:82:68,98:48:27,B0:95:75,7C:B5:9B,74:05:A5,D8:0D:17,54:75:95,C4:71:54,8C:21:0A,20:6B:E7,34:96:72,00:0A:EB,98:DE:D0,EC:08:6B,A4:2B:B0,FC:D7:33,5C:89:9A,E0:05:C5,38:83:45,EC:88:8F,64:66:B3,F0:F3:36,BC:46:99,F4:83:CD" :for i from=1 to=50 do={ :local status1 [/interface get [/interface find name=("pppoe-out".$i)] running ] :local status2 [/interface get [/interface find name=("pppoe-out".$i)] disable ] :local t [/system clock get time ] :local t1 [:pick $t 3 5]; :local t2 [:pick $t 6 8]; :local t3 ($u2+$t2); :local mac6 [:pick [:toarray $macadd] $t3] :if ($status1=false && $status2=false ) do={ :delay 1s :local vname [/interface pppoe-c get ("pppoe-out".$i) interface] :local vmac [/int vrrp get $vname mac-address] :local end6 [pick $vmac 9 17] :local vrrpmac [($mac6.":".$end6)] /log error ("新的mac地址为".$vrrpmac) /log error ("当前接口为".$vname) /log error ("老的的vrrp地址为".$vmac) /interface bridge nat set [find src-mac-address="$vmac/FF:FF:FF:FF:FF:FF"] to-src-mac-address=$vrrpmac set [find to-dst-mac-address="$vmac"] dst-mac-address=($vrrpmac."/FF:FF:FF:FF:FF:FF") /log error "vrrp mac地址更换成功" } else={:log info ("pppoe-out".$i."线路正常!")} }
单独换MAC
:local i 1 :local macadd "D0:37:45,60:3A:7C,54:A7:03,B0:BE:76,34:E8:94,AC:84:C6,94:D9:B3,B0:95:8E,C0:25:E9,24:69:68,80:89:17,00:27:19,40:16:9F,F4:EC:38,14:CF:92,20:DC:E6,14:CC:20,90:F6:52,54:C8:0F,E4:D3:32,C4:E9:84,28:2C:B2,E8:DE:27,BC:D1:77,D8:07:B6,64:6E:97,98:DA:C4,CC:08:FB,D4:6E:0E,00:14:78,30:FC:68,DC:00:77,54:E6:FC,74:EA:3A,F8:1A:67,EC:17:2F,00:19:E0,00:25:86,14:E6:E4,50:C7:BF,A8:57:4E,E8:94:F6,1C:FA:68,C0:4A:00,50:D4:F7,9C:A6:15,D0:76:E7,78:44:FD,0C:4B:54,7C:8B:CA,B0:4E:26,C0:E4:2D,8C:A6:DF,84:16:F9,18:D6:C7,08:1F:71,40:3F:8C,C0:61:18,6C:E8:73,C4:6E:1F,50:FA:84,44:B3:2D,88:25:93,D8:5D:4C,A0:F3:C1,00:1D:0F,00:23:CD,D8:15:0D,CC:34:29,68:FF:7B,80:8F:1D,0C:80:63,48:0E:EC,50:3E:AA,48:7D:2E,B8:F8:83,DC:FE:18,70:4F:57,28:EE:52,30:B4:9E,18:A6:F7,1C:44:19,F8:D1:11,B0:48:7A,94:0C:6D,64:70:02,10:FE:ED,64:56:01,EC:26:CA,14:75:90,50:BD:5F,3C:46:D8,D0:C7:C0,D4:01:6D,14:86:92,A8:15:4D,0C:82:68,98:48:27,B0:95:75,7C:B5:9B,74:05:A5,D8:0D:17,54:75:95,C4:71:54,8C:21:0A,20:6B:E7,34:96:72,00:0A:EB,98:DE:D0,EC:08:6B,A4:2B:B0,FC:D7:33,5C:89:9A,E0:05:C5,38:83:45,EC:88:8F,64:66:B3,F0:F3:36,BC:46:99,F4:83:CD" :local t [/system clock get time ] :local t1 [:pick $t 3 5]; :local t2 [:pick $t 6 8]; :local t3 ($u2+$t2); :local mac6 [:pick [:toarray $macadd] $t3] :local mac [($mac6.":".[/system clock get time])] /log error $mac :local vmac [/int vrrp get [find name=("vrrp".$i)] mac-address] /log error $vmac /interface bridge nat set [find src-mac-address="$vmac/FF:FF:FF:FF:FF:FF"] to-src-mac-address=$mac set [find to-dst-mac-address="$vmac"] dst-mac-address=($mac."/FF:FF:FF:FF:FF:FF")
备份ROS到FTP服务器
:local who [/system identity get name] :local naming ($who."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6]) /system backup save name=($naming.".backup") /tool fetch address=rizhi.371it.net port=21 src-path=($naming.".backup") user=rwc mode=ftp password=a123456 dst-path=("/ftp/rosbak/".$naming.".backup") upload=yes :delay 5s /file rem [/file find name=($naming . ".backup")]
汇报IP
:local geturl "http://log.371it.net/ip?area=lianyungang&idc=lygdt01_nobody&token=AE8E1121&" :foreach i in=[/ip address find dynamic=yes && interface~"pppoe-out"] do={ :local pppint [/ip addr get $i interface] :local ipadd [/ip addr get $i address] :local ipaddb [:pick $ipadd 0 [:find $ipadd "/"]] :local j [:pick $pppint 9 12 ] :local cururl "username=user$j&userpwd=123&ip=$ipaddb&port=3001" /tool fetch url=($geturl .$cururl) mode=http dst-path=$pppint keep-result=no }