Skip to main content

Module and script to check if local machine is on agiven network.

Project description

Module and script to test local network membership (IPv4)
===========================================================

A set of utility functions and a command-line script useful in testing local
machine membership in IPv4 networks. Requires no external modules
("batteries-included" only).

Command-line usage
++++++++++++++++++

#. Sample usage

Test all network interfaces, and return success if any interface has an IP
address in the 10.100.3.0/24 network:

.. code-block:: bash

user@localhost$ local_net 10.100.3.0/24; echo $?
0
user@localhost$

Specific interfaces may be tested by inclusion of the -i/--iface flag, which
may be repeated:

.. code-block:: bash

user@localhost$ local_net -i etho -i wlan2 192.168.1.0/24

Asserting that no local interface is a member of a given network is also
possible by using the -n/--negate flag:

.. code-block:: bash

user@localhost$ local_net -n 10.1.0.0/16


Test success or failure is indicated by exit status code - 0 for success, 1
for failure. This allows for ease of use in conditional statements and other
tests (e.g. ssh config 'exec' testing). Exit status 64 is returned if an
unrecoverable error occurs (e.g. an interface was passed that does not exist),
and error information may be written to stderr. Otherwise, no output is made.


Requirements and compatibility
++++++++++++++++++++++++++++++

The code should work on any POSIX-compatible system, but has only been tested
on modern Linux installs. Pull requests and bug reports for other operating
systems are welcome. Supports Python versions 2.6+. Python versions < 3.3
require a system libc which supports if_nameindex() to get around lack of same
in socket module.

=========
Changelog
=========
All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.

[0.2.0] - 2018-09-30
++++++++++++++++++++

Changed
-------

- Don't import ctypes until we need it.
- Catch exception from all_ifaces() in _main so we can exit correctly.
- Add LICENSE file
- Fix this CHANGELOG

[0.1.0] - 2018-09-30
++++++++++++++++++++

Added
-----

- CHANGELOG.rst
- MANIFEST.in
- README.rst
- localnet.py
- setup.cfg
- setup.py
- .gitignore


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

localnet-0.2.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

localnet-0.2.0-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file localnet-0.2.0.tar.gz.

File metadata

  • Download URL: localnet-0.2.0.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4

File hashes

Hashes for localnet-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ac4c4b1bbef5577f10a8c4889fcd31d6af89bcf40b26e297f2fb8abe45ef58e7
MD5 73d51ca9c8aedb084596f85e4d81c981
BLAKE2b-256 fc8f24137b07a29488b6c09d7e47a870c27c85caafc85e3f425d4882fe5e997e

See more details on using hashes here.

File details

Details for the file localnet-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: localnet-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/28.8.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.4

File hashes

Hashes for localnet-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58c1c88e609bbc132fa89f51069e39b370455b9b8a2a48725a029c87614c6341
MD5 33ec86e76e62bcc0d354ebaf147c1c95
BLAKE2b-256 f3f8023d3477fc1388760c4f3d8bbc0aa39be6244e1151c060b136180750da7e

See more details on using hashes here.

Supported by

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