mirror of https://github.com/aredn/aredn.git
bugfix: deal with duplicate MAC on LAN and WIFI
ref AREDN->ticket:115
This commit is contained in:
parent
0dc37a82de
commit
7985ff6ba3
|
@ -14,7 +14,7 @@ config interface lan
|
|||
option netmask <lan_mask>
|
||||
option dns "<wan_dns1> <wan_dns2>"
|
||||
option gateway <lan_gw>
|
||||
|
||||
include /etc/aredn_include/ethmacfixup
|
||||
|
||||
#### WAN configuration
|
||||
config interface wan
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue