View and modify the NIC Mac address in Centos

Source: Internet
Author: User

View and modify the NIC Mac address in Centos

Run the following command to view the Mac address of the NIC in linux/Centos:

# Ifconfig-

Eth0 Link encap: Ethernet HWaddr 00: e4: 56: 2E: D8: 20

00: e4: 56: 2E: D8: 20 is your MAC address.

In linux/Centos, temporarily modify the MAC address with the root permission:

1) Close the NIC Device

/Sbin/ifconfig eth0 down

2) modify the MAC address

/Sbin/ifconfig eth0 hw ether MAC address

3) restart the NIC

/Sbin/ifconfig eth0 up

4) check whether the modification takes effect:

Ifconfig eth0 | grep HWaddr

Note: The modified MAC address is temporary. After the system is restarted, the system restores the original physical MAC address.

How to permanently modify the MAC address of a NIC in Linux/Centos

There are many ways to modify the MAC address in linux on the Internet. After testing, the final solution is as follows:

Misunderstanding 1:

# Ifconfig eth0 down/* disable eth0 Nic. Here, the eth0 Nic is used as an example */

# Ifconfig eth0 hw ether 00: AA: BB: CC: DD: EE/* modify the MAC address of the eth0 Nic */

# Ifconfig eth0 up/* restart eth0 Nic */

Then restart the host.

Conclusion: According to this method, the MAC address is automatically restored after the host system is restarted.

Misunderstanding 2:

# Ifconfig eth0 down

# Cd/etc/sysconfig/network-scripts

# Vi ifcfg-eth0

Modify "HWADDR = xx: xx"

# Ifconfig eth0 up

# Service network start

Conclusion: The network cannot be enabled after the MAC address is modified according to this method, and the following prompt appears:

"Bringing up interface eth0: Device eth0 has different MAC address than expected, ignoring ."

To permanently Save the modified MAC address in linux/Centos, follow these steps:

# Ifconfig eth0 down

# Cd/etc/sysconfig/network-scripts

# Vi ifcfg-eth0

Modify "HWADDR = xx: xx" to "MACADDR = xx: xx"

# Ifconfig eth0 up

# Service network start

Note: The key words HWADDR and MACADDR are different.

Finally, the ifconfig command format is attached:

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.