snipez.o7
Experte
Thread Starter
- Mitglied seit
- 03.10.2016
- Beiträge
- 1.743
Ich habe vor kurzen ein kleines aber feines Feater in Tails Linux entdeckt was mir sehr gefallen hat. Nun wollte ich dieses Feater auch in Fedora 41 Workstation nutzen. Also habe ich einen systemd-service erstellt, der meine Bash nach dem Systemstart ausführen soll. So wird nun jedes mal nach einem Neustart automatisch die Mac Adresse random gewechselt. Für denjenigen die das mal ausprobieren möchten lasse ich einen Mini Guide dazu hier.
1. Systemd Service File: Create systemd service unit file.
$ sudo vim /etc/systemd/system/macads-spoof.service.
inside:
[Unit]
Description=spoof mac address on startup
After=mysql.service
[Service]
ExecStart=/usr/local/bin/spoofy.sh
[Install]
WantedBy=default.target
This sets up a service that will execute spoofy.sh after the MySQL service has started.
2. Bash Script: Create Bash that the systemd service will execute.
$ sudo vim /usr/local/bin/spoofy.sh.
inside:
#!/bin/bash
# Change the Mac address of the network interface <name> randomly
sudo macchanger -r <name>
*Type ip link show in terminal to get <name> of the interface. This will change the mac-address to a random one on startup boot.
3. Permissions: necessary permissions / systemd service at boot.
Terminal:
$ sudo chmod 744 /usr/local/bin/spoofy.sh
$ sudo chmod 664 /etc/systemd/system/macads-spoof.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable macads-spoof.service
These commands make: script executable, set appropriate permissions, reload systemd manager, and enable service to start.
reboot the system or:
4.Test the Systemd Service: Verify the script works manually.
Terminal:
$ sudo systemctl start macads-spoof.service
$ sudo systemctl status macads-spoof.service
How to: automatically execute MacAddress Spoof (macchanger) Bash at boot on systemd (Fedora41)
1. Systemd Service File: Create systemd service unit file.
$ sudo vim /etc/systemd/system/macads-spoof.service.
inside:
[Unit]
Description=spoof mac address on startup
After=mysql.service
[Service]
ExecStart=/usr/local/bin/spoofy.sh
[Install]
WantedBy=default.target
This sets up a service that will execute spoofy.sh after the MySQL service has started.
2. Bash Script: Create Bash that the systemd service will execute.
$ sudo vim /usr/local/bin/spoofy.sh.
inside:
#!/bin/bash
# Change the Mac address of the network interface <name> randomly
sudo macchanger -r <name>
*Type ip link show in terminal to get <name> of the interface. This will change the mac-address to a random one on startup boot.
3. Permissions: necessary permissions / systemd service at boot.
Terminal:
$ sudo chmod 744 /usr/local/bin/spoofy.sh
$ sudo chmod 664 /etc/systemd/system/macads-spoof.service
$ sudo systemctl daemon-reload
$ sudo systemctl enable macads-spoof.service
These commands make: script executable, set appropriate permissions, reload systemd manager, and enable service to start.
reboot the system or:
4.Test the Systemd Service: Verify the script works manually.
Terminal:
$ sudo systemctl start macads-spoof.service
$ sudo systemctl status macads-spoof.service