MAC randomisation help
MAC randomisation help
Hi!
Can anyone please help me to make my MAC be randomly generated after each reboot?
I need some kind of script or instructions. Thanks you!
Found this one:
#!/bin/sh INSTALL_PATH="/etc/init.d/randomize_mac" echo "Creating MAC randomizer script..." cat << 'EOF' > $INSTALL_PATH #!/bin/sh /etc/rc.common START=99 start() { generate_random_mac() { echo $(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256))) } change_mac() { local iface=$1 local new_mac=$(generate_random_mac) ip link set dev $iface down ip link set dev $iface address $new_mac ip link set dev $iface up } for iface in $(ip link show | grep -E '^[0-9]+:' | cut -d ':' -f 2 | cut -d ' ' -f 2); do if [ "$iface" != "lo" ]; then change_mac $iface fi done } EOF echo "Making MAC randomizer script executable..." chmod +x $INSTALL_PATH echo "Success!" echo "Enabling MAC randomizer script to run at boot time..." /etc/init.d/randomize_mac enable echo "Success!" echo "Deleting installation script..." rm -- "$0"
Here is example of output of this command:
echo $(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))":"$(printf '%02x' $((RANDOM%256)))
Output:
a7:03:f2:fa:45:5d