Home » Linux

MAC Address: How to get and set MAC in Linux?

Learn: What is MAC address in Networking, how to get and set MAC address through command line in Linux based Systems (Computer or Other devices)?

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:

A) 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.

B) 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

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.