Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15366222
  • 博文数量: 2005
  • 博客积分: 11986
  • 博客等级: 上将
  • 技术积分: 22535
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-17 13:56
文章分类

全部博文(2005)

文章存档

2014年(2)

2013年(2)

2012年(16)

2011年(66)

2010年(368)

2009年(743)

2008年(491)

2007年(317)

分类: LINUX

2009-11-24 12:22:05

luther@gliethttp:~$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:15:58:c2:85:c7 
          inet addr:172.16.32.115  Bcast:172.16.35.255  Mask:255.255.252.0
          inet6 addr: fe80::215:58ff:fec2:85c8/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:440329 errors:1088 dropped:0 overruns:0 frame:0
          TX packets:426575 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:557743309 (557.7 MB)  TX bytes:32820176 (32.8 MB)
          Interrupt:23 Base address:0xd000
先看看当前mac地址为00:15:58:c2:85:c7
luther@gliethttp:~$ sudo ifconfig eth0 down
luther@gliethttp:~$ sudo ifconfig eth0 hw ether 00:15:58:c2:85:c8
luther@gliethttp:~$ sudo ifconfig eth0 up
luther@gliethttp:~$ sudo dhclient &

如何随机产生mac地址
luther@gliethttp:~$ echo $RANDOM | md5sum | sed 's/\(..\)/&:/g' | cut -c1-17
让开机自动修改mac信息和dhcp
luther@gliethttp:~$ sudo vim /etc/rc.local
# 追加如下内容
sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether 00:15:58:c2:85:c8
sudo ifconfig eth0 up
sudo dhclient &
如果需要,可以写一个脚本,当系统运行的时候被封mac之后,直接执行如下脚本
luther@gliethttp:~$ vim mac.sh
mac="00:"`echo $RANDOM | md5sum | sed 's/\(..\)/&:/g' | cut -c1-14`
echo $mac
sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether $mac
sudo ifconfig eth0 up
sudo dhclient

08: 00: 20: 0A: 8C: 6D
一共6个字节48bits位,其中0-23位叫做组织唯一标志符 (organizationally unique ,是识别LAN(局域网)节点的标识.24-47位是由厂家自己分配。
其中第47位是组播地址标志位,47位为0为普通mac地址,为1表示广播或组播mac地址.
其中前3个字节由IEEE统一分配给网卡制造商,后3个字节由网卡制造商为自己生产的网卡对应一个唯一3字节数值,这样6个字节就构成了我们网卡的mac地址,每块网卡的mac地址唯一,不会重复 [luther.gliethttp]


阅读(9375) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~