Linux or UNIX: HowTo Find Out or Display The Ethernet Address (MAC)

Posted on in Categories FreeBSD, Linux, Networking, OpenBSD, OS X, Solaris, UNIX, Windows server last updated September 21, 2006

Media Access Control (MAC) address is a unique identifier attached to most networking devices (such as router, Ethernet cards, servers, nas devices, switches and so on).

This blog posts demonstrates how to get the Media Access Control (MAC) address for an ethernet adapter under Linux, Unix, Apple OS X, and *BSD operating systems using command line options.

Use ifconfig Command To Find Out Mac Address Under Unix Like Operating Systems

You can use the ifconfig command to view the mac address of your own computer or an ethernet adapter, enter:
# ifconfig
# ifconfig eth0

Sample outputs:

eth0      Link encap:Ethernet  HWaddr 00:08:9b:c4:30:31
          RX packets:312 errors:0 dropped:0 overruns:0 frame:0
          TX packets:45 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:26613 (25.9 KiB)  TX bytes:5439 (5.3 KiB)
          Interrupt:17 Memory:fe9e0000-fea00000

I recommend that you pass -a option to ifconfig command to get details about all interfaces which are currently available, even if down:
# ifconfig -a

Use ip Command To Find Out Mac Address Under Linux

Most modern Linux distro prefer to use the ip command:
# ip addr show
# ip addr show eth0
# ip addr show eth1
# ip addr show bond0

Sample outputs:

4: bond0:  mtu 9000 qdisc noqueue state UP
    link/ether 00:08:9b:c4:30:31 brd ff:ff:ff:ff:ff:ff
    inet brd scope global bond0
    inet6 fe80::208:9bff:fec4:3031/64 scope link tentative dadfailed
       valid_lft forever preferred_lft forever

Find out my Mac address

Use the arp command to manipulates or displays the kernel’s IPv4 network neighbour cache i.e. use the following to see your routers or other computers mac address on other end:
$ arp
Sample outputs:

Address                  HWtype  HWaddress           Flags Mask            Iface   ether   00:76:C7:76:F0:01   C                     eth0    ether   00:08:5C:00:00:01   C                     ra0

$ arp -n
Sample outputs:

Address                  HWtype  HWaddress           Flags Mask            Iface               ether   00:76:C7:76:F0:01   C                     eth0              ether   00:08:5C:00:00:01   C                     ra0


  • -n : Shows numerical addresses instead of trying to determine symbolic host, port or user names.

arp manipulates the kernel’s ARP cache in various ways. The primary options are clearing an address mapping entry and manually setting up one. The arp command works under:

  • Linux
  • *BSD
  • UNIX
  • MS Windows
  • Apple OS X and other Unix like operating systems

A Note About IBM AIX Unix Users

Type the following command to find out the mac address:
# netstat -ia

A Note About HP-UX Unix Users

Type the following command to find out the mac address:
# lanscan

Task: Changing MAC addresses

Please note that physical MAC addresses are permanent, but several mechanisms allow modification (read as spoofing) of the MAC address that is reported by the operating system. Under Linux you can type the command to setup a new MAC address :
# ifconfig eth0 down
# ifconfig eth0 hw ether 01:02:03:04:05:06


  • 01:02:03:04:05:06 – Mac address

If you are using FreeBSD type the following command:
# ifconfig nc0 ether 01:02:03:04:05:06

If you are using OpenBSD or Mac OS X type the following command:
# ifconfig nc0 lladdr 01:02:03:04:05:06

Under MS-Windows XP or 2003 server the MAC address can be changed in the Ethernet adapter’s Properties menu > Advanced tab > Look for MAC Address > Locally Administered Address > Ethernet Address > Physical Address option. Also, note that some ISP’s may use MAC addresses to control the access (a rare case these days). Therefore, if you change MAC address you may lose the connectivity to the Internet.

Page last updated at 7:44 PM, March 31, 2012.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

4 comment

  1. > Cocoro Cara July 29, 2011
    > are you sure the arp command gives the mac address of your own interface?
    > i think it is the mac of the destination interface.

    You are right. “ifconfig” tells you your own MAC address, “arp” the mac address of the other end of the same cable.

    John: at a network level, the MAC address is only visible on the same LAN segment – as soon as network packets pass through a router or gateway, they are not forwarded. That leaves Google as your only hope, but it’s a very slight one.

Leave a Comment