赵斌

赵斌的博客

他的个人主页  他的博客

修改mac地址

赵斌  2009年08月15日 星期六 01:08 | 882次浏览 | 0条评论

原文通过blogbus2zeuux工具同步发布:http://antmanler.blogbus.com/logs/43836748.html

文章发布时间:2009/3/26/9/13

10楼机房绑定了mac地址,带本的同学就不能享受高速的教育网,所以写了个脚本改mac地址
语法
sudo ./chmac
如果不指定新地址,默认恢复旧地址:

#!/bin/sh
# change MAC address
# Author : Bin Zhao
macnew = $1
fis = "${HOME}/.chmac"
if [ ! -e "$fis" ] ; then
# save the old mac address in file
echo "Here"
oldmac = ` LC_ALL = C ifconfig eth0 | grep HWaddr | awk '{print $5}' `
echo $oldmac >> $fis
fi
# there is no parameter, so change the old back
if [ ! -n "$macnew" ] ; then
# get old mac
macnew = ` cat ${ fis } `
fi
# 1. shutdown the device
sudo /sbin/ifconfig eth0 down
# 2. change the mac address
sudo /sbin/ifconfig eth0 hw ether $macnew
# 3. restart the device
sudo /sbin/ifconfig eth0 up
echo "Succeed to change you MAC address to ${macnew}"

 

评论

我的评论:

发表评论

请 登录 后发表评论。还没有在Zeuux哲思注册吗?现在 注册 !

暂时没有评论

Zeuux © 2024

京ICP备05028076号