有时候我们需要指定固定的mac地址上网

具体方法:

networksetup -listallhardwareports //查看当前所有端口Mac地址

sudo ifconfig en0 ether e4:ce:8f:32:51:82 //修改

ifconfig en1 | grep ether //查看是否修改成功,这里修改的是虚拟Mac,看硬件是看不出来的

demo案例:修改en8的mac地址

1、查看当前所有端口mac地址

apple@fenglolodeMacBook-Pro ~ % networksetup -listallhardwareports

Hardware Port: USB Ethernet

Device: en8

Ethernet Address: 00:0e:c6:68:7d:c1

Hardware Port: Wi-Fi

Device: en0

Ethernet Address: 78:4f:43:83:5a:5a

Hardware Port: Bluetooth PAN

Device: en5

Ethernet Address: 78:4f:43:84:d0:d8

Hardware Port: Thunderbolt 1

Device: en1

Ethernet Address: 82:c9:93:e2:54:01

Hardware Port: Thunderbolt 2

Device: en2

Ethernet Address: 82:c9:93:e2:54:00

Hardware Port: Thunderbolt 3

Device: en3

Ethernet Address: 82:c9:93:e2:54:05

Hardware Port: Thunderbolt 4

Device: en4

Ethernet Address: 82:c9:93:e2:54:04

Hardware Port: Thunderbolt Bridge

Device: bridge0

Ethernet Address: 82:c9:93:e2:54:01

VLAN Configurations

===================

2、修改en8的mac地址为98:ee:cb:a3:8d:bf

apple@fenglolodeMacBook-Pro ~ % sudo ifconfig en8 ether 98:ee:cb:a3:8d:bf

Password:

3、查看修改后的en8的mac地址,确认是否修改成功。

apple@fenglolodeMacBook-Pro ~ % ifconfig en8 | grep ether

ether 98:ee:cb:a3:8d:bf