Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Felix Eckhofer
tools
Commits
56077c18
Commit
56077c18
authored
Mar 28, 2014
by
Felix Eckhofer
🤹🏼
Browse files
Add randomize-mac
parent
5a8da855
Changes
2
Show whitespace changes
Inline
Side-by-side
scripts/randomize-mac/if-post-down.d/randomize-mac
0 → 100755
View file @
56077c18
#!/bin/sh
# temporarily shut down an interface and randomize the mac,
# requires the macchanger tool.
#
# place in /etc/network/if-post-down.d to renew the mac everytime
# a network interface is brought down (recent versions of
# NetworkManager no longer support if-pre-up.d)
#
# felix@tribut.de
LOGFILE
=
"
`
mktemp
`
"
PRESTATE
=
"
`
ip addr show dev
\"
$IFACE
\"
up 2>>
\"
$LOGFILE
\"
`
"
FAILED
=
"0"
date
>>
"
$LOGFILE
"
echo
"Running randomize-mac for interface '
$IFACE
'"
>>
"
$LOGFILE
"
echo
>>
"
$LOGFILE
"
[
-n
"
$PRESTATE
"
]
&&
ip
link set
dev
"
$IFACE
"
down
>>
"
$LOGFILE
"
2>&1
macchanger
-A
"
$IFACE
"
>>
"
$LOGFILE
"
2>&1
||
FAILED
=
1
[
-n
"
$PRESTATE
"
]
&&
ip
link set
dev
"
$IFACE
"
up
>>
"
$LOGFILE
"
2>&1
if
[
"
$FAILED
"
=
"1"
]
;
then
cat
"
$LOGFILE
"
| mail
-s
"[
`
hostname
`
] macchanger failed"
root
fi
rm
-f
"
$LOGFILE
"
scripts/randomize-mac/init/randomize-mac.conf
0 → 100644
View file @
56077c18
# upstart script to run randomize-mac for a list of interfaces
# place in /etc/init
# felix@tribut.de
description
"Randomize MAC address on boot"
start
on
starting
network
-
manager
pre
-
start
script
export
IFACE
for
IFACE
in
eth0
wlan1
;
do
/
etc
/
network
/
if
-
post
-
down
.
d
/
randomize
-
mac
done
end
script
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment