You are not logged in.
I've created three files:
1) ~/scripts/randomize_mac.sh
#!/bin/bash
# Change to your wireless interface
INTERFACE="wlan0"
# Generate a random MAC address
NEW_MAC=$(printf '%02x:%02x:%02x:%02x:%02x:%02x\n' $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)) $((RANDOM%256)))
# Bring the interface down
sudo ip link set dev $INTERFACE down
# Change the MAC address
sudo ip link set dev $INTERFACE address $NEW_MAC
# Bring the interface back up
sudo ip link set dev $INTERFACE upand made it executable
2) /etc/systemd/system/randomize-mac.service
[Unit]
Description=Randomize MAC Address
[Service]
Type=oneshot
ExecStart=/bin/bash /home/morphiuss/scripts/randomize_mac.sh3) /etc/systemd/system/randomize-mac.timer
[Unit]
Description=Run Randomize MAC Address
[Timer]
OnBootSec=1min
OnUnitActiveSec=3min
Unit=randomize-mac.service
[Install]
WantedBy=timers.targetThen tried to start it with:
sudo systemctl start randomize-mac.timer
But after three minutes it didn't change my MAC.
I checked the status of the services and it seems like they worked(active at needed times).
What did I do wrong?
Offline
What does the journal show at time of execution?
Offline
Is the script execute-/readable for "others"? Since you're passing a file in your home dir to a root ran service (you probably want to place that thing in a more global location in general).
Online
Yes, forgot to mention that I run chmod +x on the script.
And thanks for reminding me about journal. I'm very new to all of these things.
I was finally able to detect that it's my MAC address validity that was causing the issue.
Offline
ExecStart=/bin/bash /home/morphiuss/scripts/randomize_mac.sh => ExecStart=/home/morphiuss/scripts/randomize_mac.sh (your already calling bash in the first line)
please prepend a [SOLVED] to your original post titel by editing it if it is solved.
Last edited by jl2 (2025-01-06 14:48:19)
Why I run Arch? To "BTW I run Arch" the guy one grade younger.
And to let my siblings and cousins laugh at Arsch Linux...
Offline