blob: e6111c7be4e43700d3670d771e790fb46258d182 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# this script is part of networksettings2 package
# purpose : set fixed MAC address for network devices that
# have random addresses (like usb)
#
NS2MacStore=/etc/NS2
[ ! -d ${NS2MacStore} ] && mkdir ${NS2MacStore}
if [ -z "$1" ]
then
exit 0
fi
if [ -f ${NS2MacStore}/$1.mac ]
then
# set this mac
X=`cat ${NS2MacStore}/$1.mac`
if [ ! -z "$X" ]
then
/sbin/ifconfig $1 hw ether $X
fi
else
# remember current mac for all times
X=`/sbin/ifconfig $1 | grep HWaddr`
X=${X#*HWaddr } # strip till HWaddr
X=${X%% *} # remove trailing spaces
if [ ! -z "$X" ]
then
# valid mac address
echo ${X} > ${NS2MacStore}/$1.mac
fi
fi
exit 0
|