Run macchanger at system boot because pre-up doesn't work

Asked by Felix Triebel

The ifupdown.sh script says "NetworkManager does not run if-pre-up.d scripts", so I thought why not add a systemd service to run macchanger once during system boot. This is my modified script:

#!/bin/sh
# randomize MAC addresses of all network interfaces at boot
set -e
set -u

package=macchanger
. /etc/default/${package}

if [ "$ENABLE_ON_POST_UP_DOWN" = "true" ]; then
    for IFACE in $(ip -o link show | awk '{print $2}' | sed -e 's/:$//' | grep -v lo) ; do
        echo "IFACE='$IFACE'"
        /usr/bin/${package} -b -r $IFACE
    done
else
    echo "disabled in /etc/default/${package}"
fi

and this would be the service definition (adapted from https://unix.stackexchange.com/questions/47695/how-to-write-startup-script-for-systemd):
[Unit]
Description=Change MAC addresses

[Service]
Type=oneshot
ExecStart=/etc/macchanger/boot.sh
#RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

What you think?

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu macchanger Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

Why do you want to change your Mac address so frequently?

Revision history for this message
Felix Triebel (felix-triebel) said :
#2

Most obvious reason is enhancing privacy.
Initially I was only looking for a workaround for NetworkManager not invoking if-pre-up scripts.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

If you are behind a router it doesn't add any security whatsoever.

Can you help with this problem?

Provide an answer of your own, or ask Felix Triebel for more information if necessary.

To post a message you must log in.