Identifying an ethernet (MAC) address in Solaris
A question I have often been asked is
How to get the MAC address of an ethernet card without running ifconfig -a
as root
The simplest answer is you can't ... but oh yes you can
Updated 22-Nov-16 to include options for Solaris 11
In a nutshell, running ifconfig -a
as non-root leaves out the MAC address. But using arp
, netstat
and prtpicl
provides the necessary information - go figure!
arp
Try using arp -a
and search your own hostname, or for a shorter method:
$ arp `hostname` | cut -d' ' -f4
Note: This does not show any unconfigured NICs.
netstat
You could try netstat -pn | grep SP
. Again this provides the MAC address but also does not show unconfigured cards.
prtpicl
Using the prtpicl -c network -v
will provide the MAC address. The :local-mac-address
fields will give you what you need. It also provides the MAC addresses for any disabled interfaces.
Solaris 11 *update*
Solaris 11 introduced dladm
which is a very useful command that you can use for checking and setting all data links.
So if we wish to find the ethernet (MAC) addresses of all network interfaces on your Solaris box, we would simply issue the dladm
command with the -m option to get the list of factory MAC addresses, their slot identifiers and their availability. For example:
$ dladm show-phys -m LINK SLOT ADDRESS INUSE CLIENT net0 primary 8:0:27:4:7c:5e yes net0
According to the Oracle Solaris documentation, using dladm show-linkprop -p mac-address
is the definitive answer in Solaris 11.