Change MAC address only if needed
Some virtual interfaces have a different MAC address from their real interfaces and their drivers disallow us to change it. In this case we don't need to change the MAC address anyway. With this we can avoid errors like 'RTNETLINK answers: Invalid argument'.
This commit is contained in:
@ -488,7 +488,7 @@ if [[ $NO_VIRT -eq 0 ]]; then
|
|||||||
die "$VIRTDIEMSG"
|
die "$VIRTDIEMSG"
|
||||||
fi
|
fi
|
||||||
OLD_MACADDR=$(get_macaddr ${VWIFI_IFACE})
|
OLD_MACADDR=$(get_macaddr ${VWIFI_IFACE})
|
||||||
NEW_MACADDR=$(get_new_macaddr ${VWIFI_IFACE})
|
[[ ${OLD_MACADDR} == $(get_macaddr ${WIFI_IFACE}) ]] && NEW_MACADDR=$(get_new_macaddr ${VWIFI_IFACE})
|
||||||
WIFI_IFACE=${VWIFI_IFACE}
|
WIFI_IFACE=${VWIFI_IFACE}
|
||||||
else
|
else
|
||||||
[[ "$WIFI_IFACE" == "$INTERNET_IFACE" ]] && die "You can not share your connection from the same interface if you are using --no-virt option."
|
[[ "$WIFI_IFACE" == "$INTERNET_IFACE" ]] && die "You can not share your connection from the same interface if you are using --no-virt option."
|
||||||
@ -553,7 +553,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# initialize WiFi interface
|
# initialize WiFi interface
|
||||||
if [[ $NO_VIRT -eq 0 ]]; then
|
if [[ $NO_VIRT -eq 0 && -n "$NEW_MACADDR" ]]; then
|
||||||
ip link set dev ${WIFI_IFACE} address ${NEW_MACADDR} || die "$VIRTDIEMSG"
|
ip link set dev ${WIFI_IFACE} address ${NEW_MACADDR} || die "$VIRTDIEMSG"
|
||||||
fi
|
fi
|
||||||
ip link set down dev ${WIFI_IFACE} || die "$VIRTDIEMSG"
|
ip link set down dev ${WIFI_IFACE} || die "$VIRTDIEMSG"
|
||||||
|
Reference in New Issue
Block a user