linux/Centos下查看網卡Mac地址,輸入命令:
#ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:e4:56:2E:D8:20
00:e4:56:2E:D8:20即是你的MAC地址。
linux/Centos下以root權限臨時修改MAC地址:
1)閉網卡設備
/sbin/ifconfig eth0 down
2)修改MAC地址
/sbin/ifconfig eth0 hw ether MAC地址
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是有區別的。
最后附ifconfig命令格式:
ifconfig --help
Usage:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [metric <NN>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ...
<HW>=Hardware Type.
List of possible hardware types:
loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP)
slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP)
strip (Metricom Starmode IP) ash (Ash) ether (Ethernet)
tr (16/4 Mbps Token Ring) tr (16/4 Mbps Token Ring (New)) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel)
ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB)
arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device)
sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI)
irda (IrLAP) ec (Econet) x25 (generic X.25)
infiniband (InfiniBand)
<AF>=Address family. Default: inet
List of possible address families:
unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6)
ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE)
ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet)
ash (Ash) x25 (CCITT X.25)
|
