MAC地址随机化器-MAC地址不变吗?

时间:2019-02-16 21:36:50

标签: bash macos mac-address

我试图创建一个小的基本bash脚本,以便在重启时更改MacOS上的MAC地址。该脚本不会引发任何错误,但是也不会更改我的mac地址。

脚本:

#!/bin/bash

sudo echo "Welcome"

preAddress="$(ifconfig en0|grep ether)"

numZero=2
numOne=$(( ( RANDOM % 9 )  + 0 ))
numTwo="$(openssl rand -hex 1)"
numThree="$(openssl rand -hex 1)"
numFour="$(openssl rand -hex 1)"
numFive="$(openssl rand -hex 1)"
numSix="$(openssl rand -hex 1)"

newAddress="$numZero$numOne:$numTwo:$numThree:$numFour:$numFive:$numSix"

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport --disassociate
sudo ifconfig en0 ether $newAddress
networksetup -detectnewhardware
sudo ifconfig en0 up

echo "MAC Address changed to: $newAddress from$preAddress"

我重新使用了一些代码,这些代码最初发布在这里:Post 1 user: seren/user137369Post 2 User: Luke ExtonPost 3 User: OrangeTux/py4on

简而言之,脚本创建了一组变量,所有变量都包含一个随机数。这些变量在另一个变量中被格式化为MAC地址。然后,我将(或至少尝试)将当前的MAC地址更改为随机的MAC地址。

但是当我运行此程序时,在系统设置的“网络”>“高级”下还是在终端中运行“ ifconfig”时,我看不到任何变化?

我还尝试过将以下内容复制到终端,但没有骰子..

sudo ifconfig en0 down
sudo ifconfig en0 ether 27:ab:29:b9:be:ef
sudo ifconfig en0 up

我根本无法弄清楚为什么它不起作用。非常感谢您的帮助!

0 个答案:

没有答案