diff --git a/files/etc/config.mesh/network b/files/etc/config.mesh/network index 9854d6a5..29e926ab 100644 --- a/files/etc/config.mesh/network +++ b/files/etc/config.mesh/network @@ -14,7 +14,7 @@ config interface lan option netmask option dns " " option gateway - +include /etc/aredn_include/ethmacfixup #### WAN configuration config interface wan diff --git a/files/etc/uci-defaults/99_setup_aredn_include b/files/etc/uci-defaults/99_setup_aredn_include index b2a89fe2..a006f500 100755 --- a/files/etc/uci-defaults/99_setup_aredn_include +++ b/files/etc/uci-defaults/99_setup_aredn_include @@ -91,4 +91,34 @@ then fi +# Deal with lan and wifi having same mac address (common on TP-Link) +if [ ! -f /etc/aredn_include/ethmacfixup ] +then + mkdir -p /etc/aredn_include + touch /etc/aredn_include/ethmacfixup + local lanintf=`uci -q get 'network.lan.ifname'` + local wifiintf=`uci -q get 'network.wifi.ifname'` + local lanmac=`ifconfig $lanintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'` + local wifimac=`ifconfig $wifiintf | grep -o -E '([[:xdigit:]]{2}:){5}[[:xdigit:]]{2}'` + + + if [ "$lanmac" = "$wifimac" ] + then + local wifimacdigit=`echo $wifimac | awk 'BEGIN { FS = ":" } ;{print $4}'` + local newmac="00:00:00:00:00:00" + if [ "$wifimacdigit" = "FF" ] + then + newmac=`echo "$wifimac" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":00:"$5":"$6}'` + else + local wifimacdigitplusone + wifimacdigitplusone=`printf "%02X\n" $((0x$wifimacdigit + 1))` + newmac=`echo "$wifimac:$wifimacdigitplusone" | awk 'BEGIN { FS = ":" } ;{print $1":"$2":"$3":"$7":"$5":"$6}'` + fi + echo -e "\toption\tmacaddr\t$newmac" > /etc/aredn_include/ethmacfixup + uci -q set "network.lan.macaddr=$newmac" + uci commit + /etc/init.d/network restart + fi +fi + exit 0