Skip to content

Instantly share code, notes, and snippets.

@rcg4u
Created October 28, 2017 00:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcg4u/91cb1a17750397082910180aa075a12e to your computer and use it in GitHub Desktop.
Save rcg4u/91cb1a17750397082910180aa075a12e to your computer and use it in GitHub Desktop.
#/bin/bash
# change the mac
wan1="eth1.2"
wan2="eth1"
/sbin/ifconfig $wan1 down
/sbin/ifconfig $wan2 down
echo "Both Interfaces down"
echo "Generating a new mac address"
#macadd=$(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/:$//')
macadd="$1"
newmac=$(echo "$macadd")
sleep 2
/sbin/ifconfig $wan1 hw ether $(echo "$newmac")
/sbin/ifconfig $wan2 hw ether $(echo "$newmac")
echo "Both interfaces back up with updated mac address $macadd"
/sbin/ifconfig $wan1 up
/sbin/ifconfig $wan2 up
/sbin/uci set network.wan6.macaddr="$(echo "$newmac")"
/sbin/uci set network.wan.macaddr="$(echo "$newmac")"
echo "Mac address set to $newmac restart your cable modem"
echo "Settings verified"
/sbin/uci get network.wan6.macaddr
/sbin/uci get network.wan.macaddr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment