How to get the MAC address for a particular network

How to get the MAC address for a particular network interface?

Added: 04/09/01

From the command-line
=====================
Run lanscan(1M).

The output will look similar to this:

Hardware Station Crd Hdw Net-Interface NM MAC HP-DLPI
DLPI
Path Address In# State NamePPA ID Type Support
Mjr#
0/0/0/0 0x00306E06C47D 0 UP lan0 snap0 1 ETHER Yes 119
0/2/0/0 0x001083FB9956 1 UP lan1 snap1 2 ETHER Yes 119

The output will have one entry for each LAN card in the computer. The
second field ("Station Address") is the MAC address.

To get the MAC addresses of another machine on the LAN, try the
following:

$ ping {hostname} -n 1
$ arp -a | grep {hostname}

where {hostname} is the hostname or IP address of the remote machine.

Programmatically
================
The old (9.x) way to do this was by using the LLA (Link Level Access)
API,
which is obsolete in 10.x/11.x. The new way to do it is by using the
DLPI
(Data Link Provider Interface) API, LLA's replacement. For information
on migrating your code from LLA to DLPI, refer to chapter one of the LLA
Programming and Migration Guide (HP Part No. 98194-90053) at
<http://docs.hp.com/hpux/onlinedocs/98194-90053/00/00/1-con.html>.

You might want to check for a "logical" MAC address, rather than the
physical, if the software is going to be used in a switchover
environment.

For more information on DLPI programming, refer to the DLPI Programmer's
Guide (HP Part No. B2355-90139), available online at
<http://docs.hp.com/hpux/onlinedocs/B2355-90139/B2355-90139.html>.

Side Note
=========
To figure out what vendor made your Ethernet card based on the MAC
address, check out
<http://www.cavebear.com/CaveBear/Ethernet/vendor.html>.



Home
FAQ