diff -r fb06c8ccfd41 Lib/test/test_uuid.py --- a/Lib/test/test_uuid.py Wed Nov 19 13:21:13 2014 +0200 +++ b/Lib/test/test_uuid.py Wed Nov 19 16:14:37 2014 +0100 @@ -320,6 +320,12 @@ self.check_node(node, 'ifconfig') @unittest.skipUnless(os.name == 'posix', 'requires Posix') + def test_ip_getnode(self): + node = uuid._ip_getnode() + if node is not None: + self.check_node(node, 'ip') + + @unittest.skipUnless(os.name == 'posix', 'requires Posix') def test_arp_getnode(self): node = uuid._arp_getnode() if node is not None: diff -r fb06c8ccfd41 Lib/uuid.py --- a/Lib/uuid.py Wed Nov 19 13:21:13 2014 +0200 +++ b/Lib/uuid.py Wed Nov 19 16:14:37 2014 +0100 @@ -358,6 +358,13 @@ if mac: return mac +def _ip_getnode(): + """Get the hardware address on Unix by running ip.""" + # This works on Linux with iproute2. + mac = _find_mac('ip', 'link list', ['link/ether'], lambda i: i+1) + if mac: + return mac + def _arp_getnode(): """Get the hardware address on Unix by running arp.""" import os, socket @@ -536,8 +543,8 @@ if sys.platform == 'win32': getters = [_windll_getnode, _netbios_getnode, _ipconfig_getnode] else: - getters = [_unixdll_getnode, _ifconfig_getnode, _arp_getnode, - _lanscan_getnode, _netstat_getnode] + getters = [_unixdll_getnode, _ifconfig_getnode, _ip_getnode, + _arp_getnode, _lanscan_getnode, _netstat_getnode] for getter in getters + [_random_getnode]: try: