溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Centos系統(tǒng)下怎么查看和修改網(wǎng)卡Mac地址

發(fā)布時間:2021-08-04 17:19:38 來源:億速云 閱讀:868 作者:chen 欄目:系統(tǒng)運維

這篇文章主要講解了“Centos系統(tǒng)下怎么查看和修改網(wǎng)卡Mac地址”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Centos系統(tǒng)下怎么查看和修改網(wǎng)卡Mac地址”吧!

  本文將為大家詳細(xì)的介紹centos系統(tǒng)修改網(wǎng)卡Mac地址的方法,具體內(nèi)容如下:

  在文件/etc/sysconfig/network-scripts/ifcfg-eth0 中增加一行類似如下

  MACADDR=00:04:AC:33:1C:3B

  答:MAC地址是網(wǎng)卡的物理地址,其實在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地址的方法,大多依葫蘆畫瓢,似乎都沒驗證過,達(dá)不到修改的目的。

  經(jīng)過我的詳細(xì)測試,最終成功解決了這個問題。

  誤區(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 /*重新啟動eth0網(wǎng)卡*/

  然后重新啟動主機。

  結(jié)論:按照這種方法修改MAC地址,重新啟動主機系統(tǒng)后,MAC地址會自動還原。

  誤區(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ǎng)絡(luò),會出現(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)

感謝各位的閱讀,以上就是“Centos系統(tǒng)下怎么查看和修改網(wǎng)卡Mac地址”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Centos系統(tǒng)下怎么查看和修改網(wǎng)卡Mac地址這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI