linux/Centos下查看和修改網卡Mac地址(ifconfig命令)

本文轉載自http://www.169it.com/article/14360294838474691537.htmlhtml

linux/Centos下查看網卡Mac地址,輸入命令:linux

#ifconfig -acentos

eth0 Link encap:Ethernet HWaddr 00:e4:56:2E:D8:20網絡

00:e4:56:2E:D8:20便是你的MAC地址。測試

 

linux/Centos下以root權限臨時修改MAC地址:htm

1)閉網卡設備ip

  /sbin/ifconfig eth0 downget

2)修改MAC地址it

  /sbin/ifconfig eth0 hw ether MAC地址class

3)重啓網卡

  /sbin/ifconfig eth0 up

4)查看修改是否生效

ifconfig eth0 | grep HWaddr

注意:上述修改MAC地址只是暫時的,系統重啓後,系統會恢復原物理MAC地址。

 

Linux/Centos下如何永久修改網卡MAC地址

 

網上有不少關於linux下修改MAC地址的方法,通過測試,最終解決方法以下:

誤區一:

#ifconfig eth0 down /*禁掉eth0網卡,這裏以eth0網卡爲例*/

#ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE /*修改eth0網卡的MAC地址*/

#ifconfig eth0 up   /*從新啓動eth0網卡*/

而後從新啓動主機

結論:按照這種方法修改MAC地址,從新啓動主機系統後,MAC地址會自動還原。

誤區二:

#ifconfig eth0 down

#cd /etc/sysconfig/network-scripts

#vi ifcfg-eth0

修改其中的"HWADDR=xx:xx:xx:xx:xx:xx"

#ifconfig eth0 up

#service network start

結論:按照這種方法修改MAC地址後將沒法啓用網絡,會出現以下提示

「Bringing up interface eth0: Device eth0 has different MAC address than expected,ignoring.」

 

在linux/Centos環境下將修改後的MAC地址永久保存的正確的步驟以下:

#ifconfig eth0 down

#cd /etc/sysconfig/network-scripts

#vi ifcfg-eth0

修改其中的"HWADDR=xx:xx:xx:xx:xx:xx"爲"MACADDR=xx:xx:xx:xx:xx:xx"

#ifconfig eth0 up

#service network start

注意:關鍵詞HWADDR和MACADDR是有區別的。

相關文章
相關標籤/搜索