Tuesday, June 19, 2012

Modify Linux MAC Address

方法一

使用 ifconfig 指令的 hw class address 參數:
$ /sbin/ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

其中 xx:xx:xx:xx:xx:xx 為欲使用的 MAC address。

方法二

修改 /etc/sysconfig/network-scripts/ifcfg-eth0 檔案,使用 MACADDR 以增加欲使用的 MAC address:
MACADDR=xx:xx:xx:xx:xx:xx

執行指令:
$ sudo /sbin/ifdown eth0
$ sudo /sbin/ifup eth0
$ sudo /sbin/service network restart

參考資料 Red Hat Enterprise Linux Deployment Guide: 13.2. Interface Configuration Files

HWADDR=MAC-address where MAC-address is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive must be used in machines containing more than one NIC to ensure that the interfaces are assigned the correct device names regardless of the configured load order for each NIC's module. This directive should not be used in conjunction with MACADDR.

MACADDR=MAC-address where MAC-address is the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF. This directive is used to assign a MAC address to an interface, overriding the one assigned to the physical NIC. This directive should not be used in conjunction with HWADDR.


CentOS 6
/etc/udev/rules.d/70-persistent-net.rules 在開機時判斷 network interface 資訊。


參考資料

No comments:

Post a Comment