Skip to content

Instantly share code, notes, and snippets.

@mbierman
Last active May 16, 2024 03:54
Show Gist options
  • Save mbierman/03b2a962ac04963ef5bbc8354d0ed5d1 to your computer and use it in GitHub Desktop.
Save mbierman/03b2a962ac04963ef5bbc8354d0ed5d1 to your computer and use it in GitHub Desktop.
NOTE: Looks like Apple killed tis in Sonoma. There may be no viable workaround. If I find one, I will update this script. This allows you to create and assign any MAC address you like for macOS Wi-Fi or Ethernet connections. If you don’t supply one a random mac will be created for you.
#!/bin/bash
# v 1.0.2
# https://gist.github.com/mbierman/03b2a962ac04963ef5bbc8354d0ed5d1
# 2022 mbierman
sleep="${1:-5}"
regex="^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$"
getmac () {
rnd=$(openssl rand -hex 6 | sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/')
echo -e "What is the mac address want to set the mac\n\nexample: CA:49:63:9F:78:27\n\nLeave blank to get one generated for you."
read tmp
mac1=${tmp:=$rnd}
mac=$(echo $mac1 | tr '[:lower:]' '[:upper:]')
if [[ $mac =~ $regex ]] ; then
comp=true
echo -e "\n\n Using $mac...\n"
else
comp=false
echo false
fi
}
until [ "$comp" = "true" ]
do
getmac
done
getAdapter () {
echo "What is the adapter you want to set the mac for [en0,en1, etc. use 'ifconfig' if you don't know]"
read adapter
}
until [ "$adapter" ]
do
getAdapter
done
type=$(ifconfig $adapter | grep baseT)
if [ "$type" ]; then
echo "got Ethernet"
type="Ethernet"
else
echo "got Wi-Fi"
type="Wi-Fi"
fi
read -p "Is $adapter $type (y|n) ? " -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Exiting. Run again"
exit
fi
sudo ifconfig $adapter down && sleep $sleep && sudo ifconfig $adapter up && \
sudo ifconfig $adapter ether $mac && sudo networksetup -detectnewhardware
@mbierman
Copy link
Author

mbierman commented Aug 27, 2022

Notes

  1. On macOS the Network Settings will always show your hardware MAC address.
  2. This script’s changes are temporary. Rebooting will restore your hardware MAC address. You can also simply set the MAC address back to the hardware without rebooting.

Why?

This can be useful in some situations.

  1. Unlike iOS, macOS has no private Mac feature. Now you do.
  2. If you need to do some testing where you want to assign a specific )or random MAC address, now you can.

@phush0
Copy link

phush0 commented Sep 12, 2022

Yes this one. It works only for en0 and not any other interface

@TheJakey
Copy link

Yep same over here. Using en6 (Lenovo dock). Wasn't able to change mac add

@FASHION399
Copy link

it is not working on Macbook Pro(M1 Pro 2021)

@mbierman
Copy link
Author

mbierman commented Sep 16, 2022

@FASHION399 @phush0 @TheJakey Can you run the following and paste the result here?

bash -x randommac.sh

Also, the output from:

ifconfig

@phush0
Copy link

phush0 commented Sep 16, 2022

+ regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$'
+ '[' '' = true ']'
+ getmac
++ openssl rand -hex 6
++ sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/'
+ rnd=28:2e:cf:73:2a:48
+ echo -e 'What is the mac address want to set the mac\n\nexample: CA:49:63:9F:78:27\n\nLeave blank to get one generated for you.'
What is the mac address want to set the mac

example: CA:49:63:9F:78:27

Leave blank to get one generated for you.
+ read tmp

+ mac1=28:2e:cf:73:2a:48
++ echo 28:2e:cf:73:2a:48
++ tr '[:lower:]' '[:upper:]'
+ mac=28:2E:CF:73:2A:48
+ [[ 28:2E:CF:73:2A:48 =~ ^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$ ]]
+ comp=true
+ echo -e '\n\n Using 28:2E:CF:73:2A:48...\n'


 Using 28:2E:CF:73:2A:48...

+ '[' true = true ']'
+ '[' '' ']'
+ getAdapter
+ echo 'What is the adapter you want to set the mac for [en0,en1, etc. use '\''ifconfig'\'' if you don'\''t know]'
What is the adapter you want to set the mac for [en0,en1, etc. use 'ifconfig' if you don't know]
+ read adapter
en8
+ '[' en8 ']'
++ ifconfig en8
++ grep baseT
+ type=
+ '[' '' ']'
+ echo 'got Wi-Fi'
got Wi-Fi
+ type=Wi-Fi
+ read -p 'Is en8 Wi-Fi (y|n) ? ' -n 1 -r
Is en8 Wi-Fi (y|n) ? y+ [[ ! y =~ ^[Yy]$ ]]
+ sudo ifconfig en8 down
Password:
+ sleep 3
+ sudo ifconfig en8 up
+ sudo ifconfig en8 ether 28:2E:CF:73:2A:48
ifconfig: ioctl (SIOCAIFADDR): Can't assign requested address

ifconfig

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
anpi2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 6e:34:11:59:d3:24
	inet6 fe80::6c34:11ff:fe59:d324%anpi2 prefixlen 64 scopeid 0x4
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
anpi0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 6e:34:11:59:d3:22
	inet6 fe80::6c34:11ff:fe59:d322%anpi0 prefixlen 64 scopeid 0x5
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
anpi1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 6e:34:11:59:d3:23
	inet6 fe80::6c34:11ff:fe59:d323%anpi1 prefixlen 64 scopeid 0x6
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
ap1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether be:d0:74:6a:ef:49
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: inactive
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 6e:34:11:59:d3:02
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en6: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 6e:34:11:59:d3:03
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en7: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 6e:34:11:59:d3:04
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 36:17:0b:23:f8:40
	media: autoselect <full-duplex>
	status: inactive
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
	ether bc:d0:74:6a:ef:49
	inet6 fe80::3d:3040:8b07:4b32%en0 prefixlen 64 secured scopeid 0xd
	inet 192.168.66.184 netmask 0xffffff00 broadcast 192.168.66.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 36:17:0b:23:f8:44
	media: autoselect <full-duplex>
	status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 36:17:0b:23:f8:48
	media: autoselect <full-duplex>
	status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7e:56:cc:4e:bc:95
	inet6 fe80::7c56:ccff:fe4e:bc95%awdl0 prefixlen 64 scopeid 0x10
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
	ether 36:17:0b:23:f8:40
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x0
	member: en1 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 12 priority 0 path cost 0
	member: en2 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 14 priority 0 path cost 0
	member: en3 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 15 priority 0 path cost 0
	nd6 options=201<PERFORMNUD,DAD>
	media: <unknown type>
	status: inactive
llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7e:56:cc:4e:bc:95
	inet6 fe80::7c56:ccff:fe4e:bc95%llw0 prefixlen 64 scopeid 0x12
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::541b:fc5d:79dc:c1da%utun0 prefixlen 64 scopeid 0x13
	nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	inet6 fe80::627d:5243:f324:4974%utun1 prefixlen 64 scopeid 0x14
	nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000
	inet6 fe80::ce81:b1c:bd2c:69e%utun2 prefixlen 64 scopeid 0x15
	nd6 options=201<PERFORMNUD,DAD>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::760b:79ba:3960:cbb%utun3 prefixlen 64 scopeid 0x16
	nd6 options=201<PERFORMNUD,DAD>
en8: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=6467<RXCSUM,TXCSUM,VLAN_MTU,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
	ether 80:6d:97:0c:2d:13
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect (none)
	status: inactive

@mbierman
Copy link
Author

@phush0 please try the new version.

Also, note when it works it won't update the mac address in the Settings UI. That will always be the hardware mac, but you should see no error after running and ifconfig should show the new mac address.

Let me know if this solves the problem.

@phush0
Copy link

phush0 commented Sep 16, 2022

no change

+ sleep=2
+ regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$'
+ '[' '' = true ']'
+ getmac
++ openssl rand -hex 6
++ sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/'
+ rnd=5b:a2:35:51:81:de
+ echo -e 'What is the mac address want to set the mac\n\nexample: CA:49:63:9F:78:27\n\nLeave blank to get one generated for you.'
What is the mac address want to set the mac

example: CA:49:63:9F:78:27

Leave blank to get one generated for you.
+ read tmp

+ mac1=5b:a2:35:51:81:de
++ echo 5b:a2:35:51:81:de
++ tr '[:lower:]' '[:upper:]'
+ mac=5B:A2:35:51:81:DE
+ [[ 5B:A2:35:51:81:DE =~ ^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$ ]]
+ comp=true
+ echo -e '\n\n Using 5B:A2:35:51:81:DE...\n'


 Using 5B:A2:35:51:81:DE...

+ '[' true = true ']'
+ '[' '' ']'
+ getAdapter
+ echo 'What is the adapter you want to set the mac for [en0,en1, etc. use '\''ifconfig'\'' if you don'\''t know]'
What is the adapter you want to set the mac for [en0,en1, etc. use 'ifconfig' if you don't know]
+ read adapter
en8
+ '[' en8 ']'
++ ifconfig en8
++ grep baseT
+ type=
+ '[' '' ']'
+ echo 'got Wi-Fi'
got Wi-Fi
+ type=Wi-Fi
+ read -p 'Is en8 Wi-Fi (y|n) ? ' -n 1 -r
Is en8 Wi-Fi (y|n) ? y+ [[ ! y =~ ^[Yy]$ ]]
+ sudo ifconfig en8 down
+ sleep 2
+ sudo ifconfig en8 up
+ sudo ifconfig en8 ether 5B:A2:35:51:81:DE
ifconfig: ioctl (SIOCAIFADDR): Can't assign requested address

@phush0
Copy link

phush0 commented Sep 16, 2022

also I think grep baseT is not correct as all adapters are wifi in this way

@mbierman
Copy link
Author

mbierman commented Sep 16, 2022

@phush0 "baseT" should never be on Wi-Fi. It should be an indicator of Ethernet.

Try the same code but add this:

randommac.sh 1

Note Ethernet

bigmac:bin michael$ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	media: autoselect (1000baseT <full-duplex>)
	status: active

Note Wi-FI

bigmac:bin michael$ ifconfig en1
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
	ether 
	inet6  prefixlen 64 secured scopeid 0xc 
	inet 192.168.0.41 netmask 0xffffff00 broadcast 192.168.0.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active

@phush0
Copy link

phush0 commented Sep 16, 2022

nope, same error

@mbierman
Copy link
Author

mbierman commented Sep 16, 2022

@phush0 so I think this is a race issue. I think it will depend on how fast your machine tries to assign an IP to your adapter. Try incrementing until you find a number that works.

randommac.sh 3 if that doesn't work
randommac.sh 4...

I bet it will be consistent for your machine. ">=4" worked for me.

@FASHION399
Copy link

@mbierman

+ regex='^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$'
+ '[' '' = true ']'
+ getmac
++ openssl rand -hex 6
++ sed 's/\(..\)\(..\)\(..\)\(..\)\(..\)\(..\)/\1:\2:\3:\4:\5:\6/'
+ rnd=83:6b:07:c1:b9:3f
+ echo -e 'What is the mac address want to set the mac\n\nexample: 4C:77:CB:9A:18:89\n\nLeave blank to get one generated for you.'
What is the mac address want to set the mac

example: 4C:77:CB:9A:18:89

Leave blank to get one generated for you.
+ read tmp
4C:77:CB:9A:18:89
+ mac1=4C:77:CB:9A:18:89
++ echo 4C:77:CB:9A:18:89
++ tr '[:lower:]' '[:upper:]'
+ mac=4C:77:CB:9A:18:89
+ [[ 4C:77:CB:9A:18:89 =~ ^([0-9A-F]{2}[:]){5}([0-9A-F]{2})$ ]]
+ comp=true
+ echo -e '\n\n Using 4C:77:CB:9A:18:89...\n'


 Using 4C:77:CB:9A:18:89...

+ '[' true = true ']'
+ '[' '' ']'
+ getAdapter
+ echo 'What is the adapter you want to set the mac for [en0,en1, etc. use '\''ifconfig'\'' if you don'\''t know]'
What is the adapter you want to set the mac for [en0,en1, etc. use 'ifconfig' if you don't know]
+ read adapter
en0
+ '[' en0 ']'
++ ifconfig en0
++ grep baseT
+ type=
+ '[' '' ']'
+ echo 'got Wi-Fi'
got Wi-Fi
+ type=Wi-Fi
+ read -p 'Is en0 Wi-Fi (y|n) ? ' -n 1 -r
Is en0 Wi-Fi (y|n) ? y+ [[ ! y =~ ^[Yy]$ ]]
+ sudo ifconfig en0 down
Password:
+ sleep 2
+ sudo ifconfig en0 up
+ sudo ifconfig en0 ether 4C:77:CB:9A:18:89
ifconfig: ioctl (SIOCAIFADDR): Can't assign requested address

ifconfig

lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
	options=1203<RXCSUM,TXCSUM,TXSTATUS,SW_TIMESTAMP>
	inet 127.0.0.1 netmask 0xff000000 
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1 
	nd6 options=201<PERFORMNUD,DAD>
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
anpi2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7a:12:6c:77:28:17 
	inet6 fe80::7812:6cff:fe77:2817%anpi2 prefixlen 64 scopeid 0x4 
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
anpi1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7a:12:6c:77:28:16 
	inet6 fe80::7812:6cff:fe77:2816%anpi1 prefixlen 64 scopeid 0x5 
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
anpi0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7a:12:6c:77:28:15 
	inet6 fe80::7812:6cff:fe77:2815%anpi0 prefixlen 64 scopeid 0x6 
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en4: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7a:12:6c:77:28:f5 
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en5: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7a:12:6c:77:28:f6 
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en6: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether 7a:12:6c:77:28:f7 
	nd6 options=201<PERFORMNUD,DAD>
	media: none
	status: inactive
en1: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 36:20:31:12:2c:c0 
	media: autoselect <full-duplex>
	status: inactive
en2: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 36:20:31:12:2c:c4 
	media: autoselect <full-duplex>
	status: inactive
en3: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=460<TSO4,TSO6,CHANNEL_IO>
	ether 36:20:31:12:2c:c8 
	media: autoselect <full-duplex>
	status: inactive
ap1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether be:d0:74:4a:0e:68 
	media: autoselect
	status: inactive
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=6463<RXCSUM,TXCSUM,TSO4,TSO6,CHANNEL_IO,PARTIAL_CSUM,ZEROINVERT_CSUM>
	ether ca:49:63:9f:78:27 
	inet6 fe80::14d9:a7eb:85d7:1434%en0 prefixlen 64 secured scopeid 0xe 
	inet 192.168.1.103 netmask 0xffffff00 broadcast 192.168.1.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
bridge0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=63<RXCSUM,TXCSUM,TSO4,TSO6>
	ether 36:20:31:12:2c:c0 
	Configuration:
		id 0:0:0:0:0:0 priority 0 hellotime 0 fwddelay 0
		maxage 0 holdcnt 0 proto stp maxaddr 100 timeout 1200
		root id 0:0:0:0:0:0 priority 0 ifcost 0 port 0
		ipfilter disabled flags 0x0
	member: en1 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 10 priority 0 path cost 0
	member: en2 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 11 priority 0 path cost 0
	member: en3 flags=3<LEARNING,DISCOVER>
	        ifmaxaddr 0 port 12 priority 0 path cost 0
	nd6 options=201<PERFORMNUD,DAD>
	media: <unknown type>
	status: inactive
awdl0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether de:84:39:6d:57:b5 
	inet6 fe80::dc84:39ff:fe6d:57b5%awdl0 prefixlen 64 scopeid 0x10 
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
llw0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	options=400<CHANNEL_IO>
	ether de:84:39:6d:57:b5 
	inet6 fe80::dc84:39ff:fe6d:57b5%llw0 prefixlen 64 scopeid 0x11 
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::538e:e939:a9fe:f117%utun0 prefixlen 64 scopeid 0x12 
	nd6 options=201<PERFORMNUD,DAD>
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 2000
	inet6 fe80::d77d:71a7:334:f09d%utun1 prefixlen 64 scopeid 0x13 
	nd6 options=201<PERFORMNUD,DAD>
utun2: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1000
	inet6 fe80::ce81:b1c:bd2c:69e%utun2 prefixlen 64 scopeid 0x14 
	nd6 options=201<PERFORMNUD,DAD>
utun3: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::78f8:4e9f:d0f3:1fb3%utun3 prefixlen 64 scopeid 0x15 
	nd6 options=201<PERFORMNUD,DAD>
utun4: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1380
	inet6 fe80::6f5e:6fba:9e7d:b881%utun4 prefixlen 64 scopeid 0x16 
	nd6 options=201<PERFORMNUD,DAD>

@phush0
Copy link

phush0 commented Sep 16, 2022

well script is working only with original adapter from Apple. If I try to change mac on the dock adapter it is not working. So it sounds like Apple fault.

@mbierman
Copy link
Author

@phush0 which one is failing? en8?

@mbierman
Copy link
Author

@FASHION399 please try the new version.

@phush0
Copy link

phush0 commented Sep 16, 2022

yep en8, I tried and Dell one on en9 with same fail result

@mrrobotbot
Copy link

still trying to get it, what's the difference between this simple action that worked couple days ago for me:

  1. disconnect from wifi network (do not turn off wifi adapter)
  2. openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
  3. sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx
  4. connect back to local wlan

and this script???? o_0

@mrrobotbot
Copy link

the main difference I see is in openssl generator (syntax is a little bit different)

@acidos
Copy link

acidos commented Feb 13, 2024

This is the only script that worked for me on MacStudio Wifi / Sonoma. I will try on Macbook Pro.
Thanks a lot and please keep it alive.

@alii
Copy link

alii commented Apr 1, 2024

Thanks this is working great for en0 wi-fi!

@Brenex
Copy link

Brenex commented Apr 16, 2024

This script doesn't work for some people because when it runs "sudo ifconfig $adapter up", it auto-associates with a known SSID if a known SSID is found. The wifi adapter needs to be on and not associated for it to work. That's why the following step works, "disconnect from wifi network (do not turn off wifi adapter)".

@blueDesert
Copy link

It's not woking on MACOS sonoma 14.4.1 (23E224), MacBook Air, Apple M1.
It showed the error message: "ifconfig: ioctl (SIOCAIFADDR): Can't assign requested address"

@mbierman
Copy link
Author

This script doesn't work for some people because when it runs "sudo ifconfig $adapter up", it auto-associates with a known SSID if a known SSID is found. The wifi adapter needs to be on and not associated for it to work. That's why the following step works, "disconnect from wifi network (do not turn off wifi adapter)".

I don’t quite follow. Can you explain what you mean?

@mbierman
Copy link
Author

It's not woking on MACOS sonoma 14.4.1 (23E224), MacBook Air, Apple M1. It showed the error message: "ifconfig: ioctl (SIOCAIFADDR): Can't assign requested address"

What is the interface of your Wi-Fi adapter?

@blueDesert
Copy link

blueDesert commented May 13, 2024 via email

@blueDesert
Copy link

blueDesert commented May 13, 2024

Attached the screenshots:

img

unnamed

@mbierman
Copy link
Author

Looks like Apple killed this in Sonoma. There may be no practical workaround. If I find one, I'll update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment