Skip to main content

Enumerates all IP addresses on all network adapters of the system.

Project description

ifaddr is a small Python library that allows you to find all the IP addresses of the computer. It is tested on Linux, OS X, and Windows.

This library is open source and released under the MIT License.

You can install it with pip install ifaddr. It doesn’t need to compile anything, so there shouldn’t be any surprises. Even on Windows.

Let’s get going!

import ifaddr

adapters = ifaddr.get_adapters()

for adapter in adapters:
    print "IPs of network adapter " + adapter.nice_name
    for ip in adapter.ips:
        print "   %s/%s" % (ip.ip, ip.network_prefix)

This will print:

IPs of network adapter H5321 gw Mobile Broadband Driver
   IP ('fe80::9:ebdf:30ab:39a3', 0L, 17L)/64
   IP 169.254.57.163/16
IPs of network adapter Intel(R) Centrino(R) Advanced-N 6205
   IP ('fe80::481f:3c9d:c3f6:93f8', 0L, 12L)/64
   IP 192.168.0.51/24
IPs of network adapter Intel(R) 82579LM Gigabit Network Connection
   IP ('fe80::85cd:e07e:4f7a:6aa6', 0L, 11L)/64
   IP 192.168.0.53/24
IPs of network adapter Software Loopback Interface 1
   IP ('::1', 0L, 0L)/128
   IP 127.0.0.1/8

You get both IPv4 and IPv6 addresses. The later complete with flowinfo and scope_id.

Documentation

The complete documentation (there isn’t much to document) can be found here: ifaddr Documentation.

Bug Reports and other contributions

This project is hosted here ifaddr github page.

Alternatives

Alastair Houghton develops netifaces which can do everything this library can, and more. The only drawback is that it needs to be compiled, which can make the installation difficult.

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

ifaddr-0.1.5.tar.gz (6.4 kB view details)

Uploaded Source

File details

Details for the file ifaddr-0.1.5.tar.gz.

File metadata

  • Download URL: ifaddr-0.1.5.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Python-urllib/3.6

File hashes

Hashes for ifaddr-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2469b556bba4358754da55150ff522f9db1581dae15fb3f17e3cb69d35e84232
MD5 5c30d0e17444c714b084182ed2122abd
BLAKE2b-256 7fbd08d26d3a31b6cd0e1a771f3d322bba3f90b118ae7420254f717e8b3b95b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page