本文將為大家詳細(xì)的介紹centos系統(tǒng)修改網(wǎng)卡Mac地址的方法,具體內(nèi)容如下:
在文件/etc/sysconfig/network-scripts/ifcfg-eth0 中增加一行類(lèi)似如下
MACADDR=00:04:AC:33:1C:3B
答:MAC地址是網(wǎng)卡的物理地址,其實(shí)在Linux下也可更改MAC地址:
1)閉網(wǎng)卡設(shè)備
/sbin/ifconfig eth0 down
2)修改MAC地址
/sbin/ifconfig eth0 hw ether MAC地址
3)重啟網(wǎng)卡
/sbin/ifconfig eth0 up
Red Hat Linux下如何修改網(wǎng)卡MAC地址
OS版本:Red Hat Enterprise Linux AS4
核心:Kernel 2.6.9-42
網(wǎng)上有很多關(guān)于linux下修改MAC地址的方法,大多依葫蘆畫(huà)瓢,似乎都沒(méi)驗(yàn)證過(guò),達(dá)不到修改的目的。
經(jīng)過(guò)我的詳細(xì)測(cè)試,最終成功解決了這個(gè)問(wèn)題。
誤區(qū)一:
#ifconfig eth0 down /*禁掉eth0網(wǎng)卡,這里以eth0網(wǎng)卡為例*/
#ifconfig eth0 hw ether 00:AA:BB:CC:DD:EE /*修改eth0網(wǎng)卡的MAC地址*/
#ifconfig eth0 up /*重新啟動(dòng)eth0網(wǎng)卡*/
然后重新啟動(dòng)主機(jī)。
結(jié)論:按照這種方法修改MAC地址,重新啟動(dòng)主機(jī)系統(tǒng)后,MAC地址會(huì)自動(dòng)還原。
誤區(qū)二:
#ifconfig eth0 down
#cd /etc/sysconfig/network-scripts
#vi ifcfg-eth0
修改其中的"HWADDR=xx:xx:xx:xx:xx:xx"
#ifconfig eth0 up
#service network start
結(jié)論:按照這種方法修改MAC地址后將無(wú)法啟用網(wǎng)絡(luò),會(huì)出現(xiàn)如下提示:
“Bringing up interface eth0: Device eth0 has different MAC address than expected,ignoring.”
那么,在linux環(huán)境下如何保證修改后的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
關(guān)鍵詞:HWADDR和MACADDR是有區(qū)別的。
最后附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)
希望上文可以幫助到大家,需要的用戶快來(lái)看看吧,想了解更多精彩教程請(qǐng)繼續(xù)關(guān)注腳本之家!