linux/Centos下查看和修改网卡Mac地址(ifconfig命令)

 linux/Centos下查看网卡Mac地址,输入命令:#ifconfig -aeth0 Link encap:Ethernet HWaddr 00:e4:56:2E:D8:2000:e4:56:2E:D8:20即是你的MAC地址。linux/Centos下以root权限临时修改MAC地址:1)闭网卡设备  /sbin/ifconfig eth0 down2)修改MAC地址  /sbin/ifconfig eth0...

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命令格式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)


转自:http://www.169it.com/article/14360294838474691537.html
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值