NetworkInterface (linux): MAC address not always available #147

lbakman opened this Issue Apr 8, 2013 · 1 comment


None yet
2 participants

lbakman commented Apr 8, 2013

(Tested on CentOS 6.0 and CentOS 6.3)
It seems there may be an issue obtaining the MAC address in NetworkInterface::map if ipOnly flag is specified.

the getifaddrs() function only obtain the MAC address for interfaces of type AF_PACKET (in my experience) but not interfaces of type AF_INET.

This is not an issue if the ipOnly flag is false as the MAC address of AF_PACKET interfaces is merged with the IP address of AF_INET interfaces, but AF_PACKET interfaces are not stored in the result Map if ipOnly is true and hence the MAC address is not available.

The function ioctl using SIOCGIFHWADDR may be a more reliable way of obtaining the MAC address.

aleks-f was assigned Apr 8, 2013


aleks-f commented Apr 10, 2013

I recall this being reported before and when I looked into it worked for me on Ubuntu but perhaps I missed something. This can easily be taken care of with getifaddrs, no need to go back to ioctl, I'll look into it.

aleks-f closed this Apr 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment