Skip to content

Instantly share code, notes, and snippets.

@sylvain-reynaud
Created July 30, 2022 05:44
Show Gist options
  • Save sylvain-reynaud/31572b59ffa7d80c6da8f38dcaf5fa2b to your computer and use it in GitHub Desktop.
Save sylvain-reynaud/31572b59ffa7d80c6da8f38dcaf5fa2b to your computer and use it in GitHub Desktop.
#!/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