Merge branch 'FixupDuplicateMAC' into release-3.15.1.0

ref AREDN🎫115
This commit is contained in:
Conrad Lara - KG6JEI 2015-06-29 23:00:43 -07:00
commit 4816a47751
2 changed files with 31 additions and 1 deletions

View File

@ -14,7 +14,7 @@ config interface lan
option netmask <lan_mask> option netmask <lan_mask>
option dns "<wan_dns1> <wan_dns2>" option dns "<wan_dns1> <wan_dns2>"
option gateway <lan_gw> option gateway <lan_gw>
include /etc/aredn_include/ethmacfixup
#### WAN configuration #### WAN configuration
config interface wan config interface wan

View File

@ -91,4 +91,34 @@ then
fi 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 exit 0