Query the Kernel ARP cache for the MAC address corresponding to IP address
Project description
Python C extension to query the Kernel ARP cache for the MAC address of a given IP address.
Usage
The arpreq module exposes a single function arpreq, that will resolve a given IPv4 address into a MAC address.
An IP address can only be resolved to a MAC address if it is on the same subnet as your machine.
Let’s assume your current machine has the address 192.168.1.10 and another machine with the address 192.168.1.1 is on the same subnet:
>>> import arpreq
>>> arpreq.arpreq('192.168.1.1')
'00:11:22:33:44:55'
If a IP address can not be resolved to an MAC address, None is returned.
>>> arpreq.arpreq('8.8.8.8') is None
True
IP addresses may be also be specified as int or rich IP address data type of the common ipaddr, ipaddress, or netaddr modules.
>>> arpreq.arpreq(0x7F000001)
'00:00:00:00:00:00'
>>> import netaddr
>>> arpreq.arpreq(netaddr.IPAddress('127.0.0.1'))
'00:00:00:00:00:00'
>>> import ipaddr # on Python 2
>>> arpreq.arpreq(ipaddr.IPv4Address('127.0.0.1'))
'00:00:00:00:00:00'
>>> import ipaddress # on Python 3
>>> arpreq.arpreq(ipaddress.IPv4Address('127.0.0.1'))
'00:00:00:00:00:00'
Supported Platforms
This extension has only been tested on Linux, it should however work on any platform that supports the SIOCGARP ioctl, which is virtually every BSD, Linux and Mac OS.
Changelog
v0.3.1 (2016-07-06)
Don’t use private _PyErr_ChainExceptions (breaks on Debian Jessie)
v0.3.0 (2016-06-26)
Use PEP 489 multi-phase extension module initialization on Python 3.5+
Close socket if module initialization failed
Code cleanup
v0.2.1 (2016-06-26)
Fix memset overflow
v0.2.0 (2016-06-09)
Provide Python wheels
Support int and rich IP address objects as IP address arguments
Release the GIL during arpreq
Add units tests
Rework MAC string creation
Restructure module initialization
v0.1.0 (2015-11-28)
Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for arpreq-0.3.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf308aed0c067b47d9f855c4020564d019de242ecb397e3e202f1c5ffbddf615 |
|
MD5 | 231d0a2e602dde04046aa2301db2a92b |
|
BLAKE2b-256 | d4549a546bd435e6070337888beb3d9f854ba45f7b329ccb52463f0fe4d47836 |
Hashes for arpreq-0.3.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddc34599c99f60a6c44c10d75a05563908c10a24a8ec6ce1bb3a1f454fc23295 |
|
MD5 | da575af0e2a709c5a1de1736777ea9e8 |
|
BLAKE2b-256 | e24492859d96424a7e8073a848eabc647439259a34fd9e22a2ed882411545366 |
Hashes for arpreq-0.3.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9183a3083dcc948a9da52b3c1975dd5e70521174aafa6bed5557080f89fb2510 |
|
MD5 | fe6a5930fe55598ae8c700c965a7faaf |
|
BLAKE2b-256 | 5a8cf7909bbf7827bd642e2e57f1336b6b12636839b4db6cb034bad9a7349fd0 |
Hashes for arpreq-0.3.1-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5749a2d8ec6882dfadecc5885428a02e13f95739cebad280971e836fd5e1e868 |
|
MD5 | 64afe13f698902a5cfdfa6baf579a091 |
|
BLAKE2b-256 | 433463f82b0f6adf8e940687c73636a5ac0f78ac431c1a0f712f60233cf6edc4 |
Hashes for arpreq-0.3.1-cp33-cp33m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d34c975160fedb2e4e9382602d6a7dc17e891738a0bf6d5deca2de1219be4cbb |
|
MD5 | d6d3853326de2a4467e326bbc7874d40 |
|
BLAKE2b-256 | b0ca137b6606d161612b5fd9376d6cefaaacc863d8855cc86d10194a611b4838 |
Hashes for arpreq-0.3.1-cp33-cp33m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c2afcdba05554ca69f00cd09dd0bd3b75aad24ded80ab1e081ea34de1817a47 |
|
MD5 | 75f020786567c7140148d6cd1ce142a8 |
|
BLAKE2b-256 | e122e82247756443350a0250fca965f27fd05c7aa167a7ae9898b7dd5124b404 |
Hashes for arpreq-0.3.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d633983faa2f905f5e98c6615f86cf2483e0d5445cacabcf2876f66ef83c91a5 |
|
MD5 | 9dcac2d290634a6400e53cb6c20fd015 |
|
BLAKE2b-256 | f362a9d88d92d4acf4a5a5a52d97cbc8285854942d6286cb9085ab3ac0e62c72 |
Hashes for arpreq-0.3.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68fced1c053abf6bd4c008a32f19376ca46eef97b7405addbf34b56e48c477d7 |
|
MD5 | 4fb2d954a2c356b542c5307c70ef2052 |
|
BLAKE2b-256 | a74a8d89301fee7bd6e55515242ac1eea818973eed8efb41380caa81127300a9 |
Hashes for arpreq-0.3.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e348ab7de817b8ea5193f1663a4b711b33c6b89a6bfc024414b1af877d32074a |
|
MD5 | 24d6c944a910396900ee48734fc45700 |
|
BLAKE2b-256 | fb7452a65cc78e61b2f1a7bde2d6086d671c39c75f610a56c001094d9b60c5c7 |
Hashes for arpreq-0.3.1-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60de9dd6f7d4eca8eb39ac5e095ad0d608833234e3c9c9a515c48dc30efb9670 |
|
MD5 | 798cdeed523e85f3c9c2e985882db30a |
|
BLAKE2b-256 | 3baeb1004a1a6e069e8d3d13832548ed0cd0a34ea043402e0e578e2c16fd66b1 |
Hashes for arpreq-0.3.1-cp26-cp26mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 969d9d5035193ecfc32cef2f7d0fdcda38ec2361ec05c99497851468ab109529 |
|
MD5 | 61cbdccbd47ae35e8cbd3ce323e5416e |
|
BLAKE2b-256 | 546c7ddb6ef166beb75e497cb3ec9b8e7484ea91676c5849b9bdacc9a37a6515 |
Hashes for arpreq-0.3.1-cp26-cp26mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a7bae8bee8fb715840e534e21b76114c14c506c199d138bb8488e02e0177918 |
|
MD5 | f45e731c94411064e9baaafabda922ce |
|
BLAKE2b-256 | 3735654a0fde7dd78f89f96c784af948d407f827ed1d01f8c64b3284fe48a4bb |
Hashes for arpreq-0.3.1-cp26-cp26m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35cddc25135caac9c0dd0cb129be626de9f3d4f8704f725e9de8b508bd210133 |
|
MD5 | b0ecb2ee59f29fc9076696e025ae64b6 |
|
BLAKE2b-256 | cf4b295b7f514d68df19d252945e643e6a9ec7b4bb4ff45f4ff01800d61a4c5f |
Hashes for arpreq-0.3.1-cp26-cp26m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2897a5e46e76b63eb66833f54ed0dce0c78cca287d83353299c0aed3d07cd63b |
|
MD5 | fd45017178788381b8d5195a2e70d8b0 |
|
BLAKE2b-256 | 7734cfbce43c41afd8773a12c9bfd9ad1e15c90c847ea387abe9cd2d151a52a9 |