author | wimpie <wimpie> | 2005-01-06 23:48:02 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-06 23:48:02 (UTC) |
commit | a056b6d067800486d9c1ce99d1b923289d335e8f (patch) (unidiff) | |
tree | e6f1f78a2d7a26d88033e1c3fcf8f99e4e26422e /bin/NS2SetMac.sh | |
parent | 006091cfc3bb54286fd4dd74773fe5c09048077b (diff) | |
download | opie-a056b6d067800486d9c1ce99d1b923289d335e8f.zip opie-a056b6d067800486d9c1ce99d1b923289d335e8f.tar.gz opie-a056b6d067800486d9c1ce99d1b923289d335e8f.tar.bz2 |
Script to remember and set MAC address for devices that
randomly generate a mac address and cause problems with proper dhcp
and ssh
-rwxr-xr-x | bin/NS2SetMac.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/bin/NS2SetMac.sh b/bin/NS2SetMac.sh new file mode 100755 index 0000000..51810ae --- a/dev/null +++ b/bin/NS2SetMac.sh | |||
@@ -0,0 +1,22 @@ | |||
1 | # store/set MAC address for given interface | ||
2 | NS2MacStore=/etc/NS2 | ||
3 | |||
4 | [ ! -d ${NS2MacStore} ] && mkdir ${NS2MacStore} | ||
5 | |||
6 | if [ -z "$1" ] | ||
7 | then | ||
8 | exit 0 | ||
9 | fi | ||
10 | |||
11 | if [ -f ${NS2MacStore}/$1.mac ] | ||
12 | then | ||
13 | # set this mac | ||
14 | /sbin/ifconfig $1 hw ether `cat ${NS2MacStore}/$1.mac` | ||
15 | else | ||
16 | # remember current mac for all times | ||
17 | X=`/sbin/ifconfig $1 | grep HWaddr` | ||
18 | X=${X#*HWaddr } # strip till HWaddr | ||
19 | X=${X%% *} # remove trailing spaces | ||
20 | echo ${X} > ${NS2MacStore}/$1.mac | ||
21 | fi | ||
22 | exit 0 | ||