找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 58170|回复: 27

OPENWRT修改MAC终极教程

 火.. [复制链接]
版本:OpenWrt | OpenWrt Backfire 10.03.1
问题:多台openwrt设备在同一网络中使用产生MAC冲突

解决过程:
(红色的为新增加的部分)
1.修改 lan,wan mac地址
编辑 /etc/config/network
修改其中一段
config 'interface' 'lan'
        option 'type' 'bridge'
        option 'ifname' 'eth0.0'
        option 'proto' 'static'
        option 'netmask' '255.255.255.0'
        option 'ipaddr' '192.168.200.1'
        option 'macaddr' 'd8:64:c7:5e:f1:c6'

config 'interface' 'wan'
        option 'ifname' 'eth0.1'
        option 'proto' 'dhcp'
        option 'macaddr' 'd8:64:c7:5e:f1:c6'

2.修改 eth0 mac地址
编辑 /etc/rc.local
ifconfig eth0 down;ifconfig eth0 hw ether d8:64:c7:5e:f1:c6;ifconfig eth0 up

3.修改wireless mac地址
这就最纠结了直接修改 /etc/config/wireless中的mac是没用的,并且修改后无线网络会无法启动。
在研究了/sbin/wifi脚本后,只能通过迂回战术来进行解决。
编辑 /sbin/wifi
修改如下一段,增加内容
set_wifi_up() {                                                   
        echo wifi_up;ls /tmp/run/*.conf         

        kill `cat /var/run/wifi-phy0.pid`      
        sed -i s/^bssid=.*/bssid=d8:64:c7:5f:f1:c6/ /var/run/hostapd-phy0.conf
        hostapd -P /var/run/wifi-phy0.pid -B /var/run/hostapd-phy0.conf

        local cfg="$1"                        
        echo wifi_up 2;ls /tmp/run/*.conf
        local ifname="$2"                     
        echo wifi_up 3;ls /tmp/run/*.conf
        uci_set_state wireless "$cfg" up 1
        uci_set_state wireless "$cfg" ifname "$ifname"

}        

4.修改完成
sync;reboot  重启,就能看到所有修改都生效了。











评分

参与人数 3恩山币 +3 收起 理由
gdi*** + 1 强大的恩山!(以下重复1万次)
玉树*** + 1 其实可以进breed里面改,不用那么麻烦,但还是支持一下。
zhen*** + 1 实用技术,强

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
是我需要的,试试看。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

lan和wan地址一样,不会有问题吗?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| | 显示全部楼层
霏臻 发表于 2013-8-4 14:10
lan和wan地址一样,不会有问题吗?

默认刷好op,可以看一下,全部mac都死一样的也没出问题。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

非常有用。试一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

都一样。。。不好吧。。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

还真没弄懂...
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

修改配置就能修改MAC地址吗?你修改后查看MAC地址了吗?用什么命令查看的?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

必须是在 OpenWrt Backfire 10.03.1的版本下才有用吗?其他版的可以不?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

楼主厉害,这个教程收藏了,以后估计能用上。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

最好只改最后两位,其他位改了实测可能会有问题
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

eth0的mac是从ART里面读到的,wlan0 的mac地址 是从哪里生成的呢? 规则在哪里啊
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

直接用breed uboot那个不行吗。。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

楼主很厉害,已经完美解决了mac修改的问题

点评

有教程吗 多谢  详情 回复 发表于 2023-5-25 14:07
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

mark>被用了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

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

本版积分规则

关闭

欢迎大家光临恩山无线论坛上一条 /1 下一条

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-30 21:55

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

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