找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 88|回复: 2

[脚本] 帮忙修改 RouterOS 随机修改 mac 地址 脚本

[复制链接]
发表于 3 天前 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
本帖最后由 ai188 于 2025-5-19 21:55 编辑

帮忙修改个脚本  在V6 版本中运行不了
{
:global hex ("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
/interface wireless
:local lini [find default-name~"wifi-vpn-"]
:local maci ($hex . $hex)
:global macrun 0
:local linkname
:local a
:local b
:local c
:local d
:local i 1
:local starttime [/system resource get uptime]
:local startuptime [:tonum $starttime]
:local starthour (($startuptime / 3600) % 24)
:local startminute (($startuptime / 60) % 60)
:local startsecond ($startuptime % 60)
:foreach ii in=$lini do={
  :set linkname [get $ii name]
  :local currenttime [/system clock get time]
  :local currenthour [:pick $currenttime 0 2]
  :local currentminute [:pick $currenttime 3 5]
  :local currentsecond [:pick $currenttime 6 8]
  :set a [:pick $maci (($starthour + $currenthour) % 256)]
  :set b [:pick $maci (($startminute + $currentminute) % 256)]
  :set c [:pick $maci (($startsecond + $currentsecond) % 256)]
  :set d [:pick $maci ($i % 256)]
  :set i ($i + 1)
  :local newmac ("04:6C:9D:" . $a . ":" . $b . ":" . $c)
  :log warning ("Set $linkname Mac $newmac")
  :put ("Set $linkname Mac $newmac")
  # 使用 :set 命令设置 MAC 地址
   set $ii mac-address=$newmac
  :delay 2s
}
}

routeros
 楼主| 发表于 3 天前 | 显示全部楼层
本帖最后由 ai188 于 2025-5-19 21:55 编辑

V7正常



{
:global hex ("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
/interface wireless
:local lini [find name"wifi"]
:local maci ($hex . $hex)
:global macrun 0
:local linkname
:local a
:local b
:local c
:local d
:local i 1
:local starttime [/system resource get uptime]
:local startuptime [:tonum $starttime]
:local starthour (($startuptime / 3600) % 24)
:local startminute (($startuptime / 60) % 60)
:local startsecond ($startuptime % 60)
:foreach ii in=$lini do={
  :set linkname [get $ii name]
  :local currenttime [/system clock get time]
  :local currenthour [:pick $currenttime 0 2]
  :local currentminute [:pick $currenttime 3 5]
  :local currentsecond [:pick $currenttime 6 8]
  :set a [:pick $maci (($starthour + $currenthour) % 256)]
  :set b [:pick $maci (($startminute + $currentminute) % 256)]
  :set c [:pick $maci (($startsecond + $currentsecond) % 256)]
  :set d [:pick $maci ($i % 256)]
  :set i ($i + 1)
  :local newmac ("00:6C:9D:" . $a . ":" . $b . ":" . $c)
  :log warning ("Set $linkname Mac $newmac")
  :put ("Set $linkname Mac $newmac")
   set $ii mac-address=$newmac
  :delay 2s
}
}
routeros
回复

使用道具 举报

 楼主| 发表于 3 天前 来自手机 | 显示全部楼层
/interface wireless
:local lini [find default-name~"wifi-vpn-"]
问题是在V6中 获取不到虚拟接口的default-name,只能获取到物理接口。
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2025-5-22 04:04 , Processed in 0.134875 second(s), 14 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表