zoukankan      html  css  js  c++  java
  • linux/Centos下查看和修改网卡Mac地址(ifconfig命令)

    本文转载自http://www.169it.com/article/14360294838474691537.html

    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是有区别的。

  • 相关阅读:
    SEO搜索引擎
    SEO
    编程的智慧
    ES6编程规范
    面试题集
    motto
    motto
    JS
    motto
    Linux
  • 原文地址:https://www.cnblogs.com/yzj-blog/p/7736299.html
Copyright © 2011-2022 走看看