Mikrotik Ros 脚本

关闭某个物理网口5秒钟

:if ([/interface get [/interface find name="xbo1"] disable]=false) do={/interface set [/interface find name="xbo1"] disable=yes}

:delay 5;

/interface set [/interface find name="xbo1"] disable=no

设置备份,请设置权限为rrwt

 
:local from "[email protected]" 
:local user "rxxx" 
:local password "xxxx123"
:local to "[email protected]" 

:local address "101.210.101.111" 
:local router "xxxBackup" 

/system backup save name=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6]);  
 
:delay 1; 

/tool e-mail send server=($address) port=25 from=($from) user=($user) password=($password) to=($to) subject=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup") file=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup") body=($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup"); 
 
:delay 20; 

/file remove ($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".backup"); 
#/file remove ($router."-".[:pick [/system clock get date] 7 11].[:pick [/system clock get date] 0 3].[:pick [/system clock get date] 4 6].".umb");
:log warning "backup send [email protected]"

打开关闭路由

/ip route disable [/ip route find comment=tel02]
/ip route enable [/ip route find comment=tel01]
/ip dns cache flush