Windows 下修改 MAC 容易,Linux 較繁瑣。在 VMware 虛擬機中,提供三種層級的修改方案,按需選擇。
.vmx 設定檔(最推薦,等同重燒實體網卡 ROM)關閉虛擬機,編輯 xxxx.vmx,視情況修改:
ethernet0.addressType = "static"
ethernet0.address = "00:50:56:0A:0B:0C"
static 表示手動指定ethernet0.addressType = "generated"
uuid.location = "56 4d dc f1 ff aa 75 ea-f1 b9 ee 0d 68 9c 65 5c"
uuid.bios = "56 4d ed 23 13 8c 96 91-7c 68 b2 09 8b aa bb cc"
ethernet0.generatedAddress = "00:0c:29:aa:bb:cc"
generated 表示由 UUID 派生uuid.bios 最後 6 位元組 + ethernet0.generatedAddress 最後 6 位元組/etc/rc.local(系統啟動時生效,簡單直接)# vi /etc/rc.local
ifconfig eth0 down
ifconfig eth0 hw ether 00:11:22:33:44:55
ifconfig eth0 up
重啟後生效。適用於不想動虛擬機設定、僅在客體 OS 層面修改的場景。
/etc/sysconfig/network-scripts/ifcfg-eth0(Red Hat 系標準做法)# vi /etc/sysconfig/network-scripts/ifcfg-eth0
MACADDR=00:11:22:33:44:55
# :wq 存檔
# reboot
網路服務重啟或系統重啟生效。配合 HWADDR 可綁定實體裝置,防止介面名稱漂移。
| 需求 | 推薦方法 |
|---|---|
| 永久、底層、跨客體 OS 生效 | 方法一 (.vmx) |
| 快速驗證、不修改虛擬機設定 | 方法二 (rc.local) |
| 生產環境規範管理、配合網路腳本 | 方法三 (ifcfg-eth0) |
三法任選其一即可,切勿同時使用避免衝突。