文章发布时间: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}"
暂时没有评论