當前位置:首頁 » 操作系統 » linux配置mac地址

linux配置mac地址

發布時間: 2025-01-30 17:28:37

1. linux修改mac地址

linux修改mac地址需要分四步進行,下面是具體介紹:
1、查看網卡的MAC地址,ifconfig,可以看到HWaddr即是網卡物理地址;


以上就是小編今天的分享了,希望可以幫助到大家。
本文章基於thinkpadE15品牌、centos7系統撰寫的。

2. linux修改Mac地址

1、臨時性的修改:

依次輸入以下命令:

/sbin/ifconfig eth0 down

/sbin/ifconfig eth0 hw ether 00:0C:29:36:97:20

/sbin/ifconfig eth0 up

service network restart

2、永久性的修改:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

添加MACADDR=00:0C:29:36:97:20

注釋掉原來的HWADDR

:wq 保存退出。

有危害,如果永久激活步驟錯誤則會造成無法聯網的問題。

(2)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地址會自動還原。

3. linux修改mac地址命令

1.臨時性的修改:

①依次輸入以下命令:

/sbin/ifconfig eth0 down/sbin/ifconfig eth0 hw ether 00:0C:29:36:97:20/sbin/ifconfig eth0 upservice network restart

2.永久性的修改:

方法①:

並把類似於1中的②腳本保存在/etc/rc.local中:這一步是起作用的關鍵步驟
腳本如下:

/sbin/ifconfig eth0 down/sbin/ifconfig eth0 hw ether 00:0C:29:36:97:20/sbin/ifconfig eth0 upservice network restart

方法②:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

添加

MACADDR=00:0C:29:36:97:20

  • 注釋掉原來的HWADDR

  • :wq

  • 保存退出。

    方法③:

    直接編輯 /etc/network/interfaces 文件,在 iface eth0 inet static 後面添加一行:

  • pre-up ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx(要改成的MAC)


  • 編輯interfaces文件

  • sudo nano /etc/network/interfaces


  • 如下所示:

  • face eth0 inet staticpre-up ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx(要改成的MAC)address 192.168.1.10netmask 255.255.255.0gateway 192.168.1.1

  • 重啟網卡

  • sudo /etc/init.d/networking restart

  • 註:MAC地址由udev在系統啟動時探測網卡並載入,可在以下兩個文件中反映出來
    /sys/class/net/eth0/address 《Linux就該這么學》 一起學習linx

    /etc/udev/rules.d/70-persistent-net.rules —-修改無效,根據硬體自動生成的文件

    不過,用ifconfig修改了mac後,

    /sys/class/net/eth0/address 的值隨即跟著變了;但 /etc/udev/rules.d/70-persistent-net.rules 卻沒有變,只有在udev探測到硬體發生變化時才會修改這個文件。

4. linux修改Mac地址

有三種方法: 方法一: 1.關閉網卡設備 ifconfig eth0 down 2.修改MAC地址 ifconfig eth0 hw ether MAC地址 3.重啟網卡 ifconfig eth0 up 方法二: 以上方法一修改後linux重啟後MAC又恢復為原來的,為了下次啟動時修改後的MAC仍有效,我們可以修改文件file:/etc/rc.d/rc.sysinit(RedFlag Linux為這個文件,其他版本的linux應該不同)的內容,在該文件末尾加以下內容: ifconfig eth0 down ifconfig eth0 hw ether MAC地址 ifconfig eth0 up 方法三: 很簡單的,只是在./etc/sysconfig/network-scripts/ifcfg-eth0中加入下面一句話: MACADDR=00:AA:BB:CC:DD:EE

熱點內容
連接ftp異常中斷 發布:2025-09-16 12:52:33 瀏覽:287
3m移動辦公伺服器地址大全 發布:2025-09-16 12:22:35 瀏覽:256
什麼是直男的快樂密碼 發布:2025-09-16 12:22:32 瀏覽:910
修改資料庫存儲引擎 發布:2025-09-16 12:21:48 瀏覽:77
安徽調度伺服器品牌雲伺服器 發布:2025-09-16 12:02:17 瀏覽:777
資料庫表設計教程 發布:2025-09-16 10:50:47 瀏覽:348
朋友圈緩存如何清除 發布:2025-09-16 10:49:57 瀏覽:446
sqlserver數據類型 發布:2025-09-16 10:41:16 瀏覽:740
如何配置全站時間同步系統 發布:2025-09-16 10:19:13 瀏覽:177
java解析json文件 發布:2025-09-16 10:10:41 瀏覽:977