@@ -370,8 +370,9 @@ def _find_mac(command, args, hw_identifiers, get_index):
370370def _ifconfig_getnode ():
371371 """Get the hardware address on Unix by running ifconfig."""
372372 # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.
373+ keywords = (b'hwaddr' , b'ether' , b'address:' , b'lladdr' )
373374 for args in ('' , '-a' , '-av' ):
374- mac = _find_mac ('ifconfig' , args , [ b'hwaddr' , b'ether' ] , lambda i : i + 1 )
375+ mac = _find_mac ('ifconfig' , args , keywords , lambda i : i + 1 )
375376 if mac :
376377 return mac
377378
@@ -391,7 +392,20 @@ def _arp_getnode():
391392 return None
392393
393394 # Try getting the MAC addr from arp based on our IP address (Solaris).
394- return _find_mac ('arp' , '-an' , [os .fsencode (ip_addr )], lambda i : - 1 )
395+ mac = _find_mac ('arp' , '-an' , [os .fsencode (ip_addr )], lambda i : - 1 )
396+ if mac :
397+ return mac
398+
399+ # This works on OpenBSD
400+ mac = _find_mac ('arp' , '-an' , [os .fsencode (ip_addr )], lambda i : i + 1 )
401+ if mac :
402+ return mac
403+
404+ # This works on Linux, FreeBSD and NetBSD
405+ mac = _find_mac ('arp' , '-an' , [os .fsencode ('(%s)' % ip_addr )],
406+ lambda i : i + 2 )
407+ if mac :
408+ return mac
395409
396410def _lanscan_getnode ():
397411 """Get the hardware address on Unix by running lanscan."""
0 commit comments