爱意满满的作品展示区。
Missex

分享个让 openwrt 的 wifi 使用随机 mac 的脚本

  •  
  •   Missex · Aug 11, 2014 · 8297 views
    This topic created in 4336 days ago, the information mentioned may be changed or developed.
    /etc/rc.local 中写入如下内容

    random_mac(){
    local i; for i in wireless.@wifi-iface[0] network.lan; do
    local mac; while [ "${#mac}" != "17" ]; do
    mac=00$(hexdump -n5 -e '/1 ":%02x"' /dev/urandom)
    done
    echo ${mac}
    uci set ${i}.macaddr=${mac}
    uci commit ${i%%.*}
    unset mac
    done
    }; random_mac

    这样每次启动后都生成随机mac,下次启动后就使用这个mac,但是本次由于网络相关的
    东西已经启动,使用的还是原来的mac,第一次用这个脚本可以手动执行一下。

    不是每天重启路由器的可以用cron定期执行这个脚本,在done后面加上 ifup lan; wifi 即


    这个做的原因是有些手机软件会把GPS信息和无线mac做关联,关闭GPS甚至没有GPS的
    平板只要连入这个路由器也能被定位了。我个人感觉不爽。

    不过即便不接入路由器,那些软件好像还能通过扫描周围已关联位置的无线信息进行定
    位(这种精度好像低一些)。好在我这里无线信号比较稀疏。 但是如果使用随机的mac
    的人多了之后,mac定位数据库也就越来越混乱了,慢慢就失去作用了。

    ps: mac格式前面的00好像不是必须的。那个hexdump的参数只能在openwrt下运行,
    linux上不行。用while把hexdump包起来是因为我这有时候产生00:12:34*:56 这样的
    mac,检查一下长度保证后面不会弄错。
    同时修改两个wireless.@wifi-iface[0] network.lan这两个是因为用NirSoft的WirelessNetView
    看到的mac是前者的,用arp -a看到的是后者的,没细研究,干脆都改了。
    7 replies    2015-06-08 15:57:04 +08:00
    Missex
        3
    Missex  
    OP
       Aug 11, 2014
    v2ex 不能删楼啊,还不能编辑
    xieranmaya
        4
    xieranmaya  
       Aug 11, 2014
    所以要贴gist,可以编辑的
    Missex
        5
    Missex  
    OP
       Aug 11, 2014
    @xieranmaya 匿名的也可以编辑么
    xieranmaya
        6
    xieranmaya  
       Aug 12, 2014
    @Missex gist都是有主人的啊好像
    orcusfox
        7
    orcusfox  
       Jun 8, 2015
    挖个坟 openwrt有个包叫macchanger
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5168 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 46ms · UTC 09:23 · PVG 17:23 · LAX 02:23 · JFK 05:23
    ♥ Do have faith in what you're doing.