How to Get and Set MAC Address in Linux?

What is MAC Address?

MAC Address stands for Media Access Control Address, which is a unique identifier assigned to any computer's network interface. Which plays an important role while communicating with other device connected in the network at Data Link Layer of a Network Segment.
Reference: MAC_Address

MAC address is also known as hardware address. It's a physical address of any device which is connected or which will be connected with a network.

We cannot change MAC address of a device frequently just like IP address (Read: How to set IP Address in Linux) and other network settings, it is defined by the manufacturer of the product.

Mac Address in Linux

How to get and set MAC Address in Linux?

MAC Address can be get and set through ifconfig command in Linux, consider the given syntax and example:

Command to get MAC Address in Linux Operating System

Syntax:

ifconfig -a

Note: The command and/or its parameters may be different for different Linux flavors.

Command to set MAC Address in Linux Operating System

Syntax:

ifconfig <network interface> hw ether <mac address>

Example:

ifconfig eth0 hw ether 00:BF:48:BA:DA:AB

Note: To execute above command we should have root permissions. To set MAC address we have down and up network link.

ifconfig eth0 down
ifconfig eth0 hw ether 00:BF:48:BA:DA:AB
ifconfig eth0 up

To set MAC address first we down network link and then set MAC address to device and then we up network link.

Note:
MAC address is unique for every network related device. Two devices cannot hold same MAC address. If two devices hold same MAC address then network will not be reachable due to MAC confliction. So, MAC address related settings should be used carefully.


Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.