Created
July 30, 2022 05:44
-
-
Save sylvain-reynaud/31572b59ffa7d80c6da8f38dcaf5fa2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Change MAC address | |
## Find the device used to be connected to internet : mine is wlp2s0 | |
ip link ls | |
## Set the DEVICE variable | |
DEVICE=wlp2s0 | |
## Backup the old MAC address | |
ip link show ${DEVICE} | tail -1 | cut -d" " -f 6 >> ~/${DEVICE}_mac_address_history | |
## Stop the device to manipulate it | |
sudo ip link set dev ${DEVICE} down | |
## Change its MAC address (TODO : set the MAC address) | |
sudo ip link set dev ${DEVICE} address XX:XX:XX:a$((1 + $RANDOM % 9)):a$((1 + $RANDOM % 9)):a$((1 + $RANDOM % 9)) | |
## Start the device | |
sudo ip link set dev ${DEVICE} up | |
# Release an IP address for the device interface: | |
sudo dhclient -r ${DEVICE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment