1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
CLI tool
========
The netaddr package includes a ``netaddr`` CLI application.
.. note::
The tool is meant to be used by humans. Its interface should not be considered stable.
Exercise caution when using it in any kind of programmatic context (read: scripting).
If you want a stable interface use the :doc:`programmatic API <../api>`.
To see the usage ::
% netaddr --help
__ __ __
____ ___ / /_____ _____/ /___/ /____
/ __ \/ _ \/ __/ __ `/ __ / __ / ___/
/ / / / __/ /_/ /_/ / /_/ / /_/ / /
/_/ /_/\___/\__/\__,_/\__,_/\__,_/_/
usage: netaddr [-h]
The netaddr CLI tool
options:
-h, --help show this help message and exit
Share and enjoy!
.. _interactive-shell:
Interactive shell
-----------------
Calling ``netaddr`` without any arguments will launch an interactive shell.
The shell uses `IPython`_ if available or the built-in Python REPL otherwise. The IPython REPL
has more features and offers nicer experience overall.
The shell comes with all parts of :doc:`the netaddr API <../api>` pre-imported so you can
interact with it right away, with minimal friction:
::
% netaddr
__ __ __
____ ___ / /_____ _____/ /___/ /____
/ __ \/ _ \/ __/ __ `/ __ / __ / ___/
/ / / / __/ /_/ /_/ / /_/ / /_/ / /
/_/ /_/\___/\__/\__,_/\__,_/\__,_/_/
netaddr shell 1.0.0 - an interactive shell for the netaddr library
In [1]: '10.0.0.2' in IPNetwork('10.0.0.0/24')
Out[1]: True
In [2]:
.. versionchanged:: 1.2.0
Made IPython an optional dependency.
.. _IPython: https://pypi.org/project/ipython/
.. _cli-network-info:
Network information
-------------------
Run ``netaddr info <network>`` to display information about an IP network::
% netaddr info 192.2.2.27/24
__ __ __
____ ___ / /_____ _____/ /___/ /____
/ __ \/ _ \/ __/ __ `/ __ / __ / ___/
/ / / / __/ /_/ /_/ / /_/ / /_/ / /
/_/ /_/\___/\__/\__,_/\__,_/\__,_/_/
IP network information
CIDR 192.2.2.0/24
Network IP 192.2.2.0
Network IP (binary) 11000000.00000010.00000010.00000000
Network IP (decimal) 3221357056
Network IP (hex) 0xc0020200
Subnet mask 255.255.255.0
Subnet mask (binary) 11111111.11111111.11111111.00000000
Broadcast IP 192.2.2.255
Range 192.2.2.0-192.2.2.255
Total addresses 256
Usable range 192.2.2.1-192.2.2.254
Usable addresses 254
|