将以下代码放到开机脚本/etc/rc.local即可
#step4 set MAC file or read and set MAC
if[! -f "/etc/maccfg"];then
s1="MAC0=308999"
s2=$(cat /dev/urandom | head -n 6 | md5sum | head -c 6)
s3=${s1}${s2}
echo "set random $s3"
echo $s3 > /etc/maccfg
fi
if[-r /etc/maccfg];then
. /etc/maccfg
ifconfig eth0 down
ifconfig eth0 hw ether "$MAC0"
fi
网友评论