-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmac-changer
55 lines (47 loc) · 1.17 KB
/
mac-changer
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# little bash script that changes your mac
# first parameter is the interface on which you want to change the mac
# ------> e for eth0
# ------> w for wlan0
# second parameter is your new mac
# ------> if no mac is specified, one will be randomly assigned
# if you see this error:
# (SIOCSIFHWADDR: Cannot assign requested address)
# just run the script again
#
# example : ./mac-changer e 11:22:33:44:55:66 (wont work, i know, just use an appropiate mac address)
#
# enjoy!
newmac=$2
if [ $2 = ]
then
newmac=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')
fi
echo
echo '################################'
echo '### MACs for eth0 and wlan0: ###'
ifconfig eth0 | grep HWaddr | awk '{print $5}'
ifconfig wlan0 | grep HWaddr | awk '{print $5}'
echo '### New MAC is: ###'
echo '>>>>>' $newmac '<<<<<'
echo '################################'
echo
function changemacwlan0 {
sudo ifconfig wlan0 down
sudo ifconfig wlan0 hw ether $newmac
sudo ifconfig wlan0 up
}
function changemaceth0 {
sudo ifconfig eth0 down
sudo ifconfig eth0 hw ether $newmac
sudo ifconfig eth0 up
}
if [ $1 = w ]
then
changemacwlan0
fi
if [ $1 = e ]
then
changemaceth0
fi
exit 0