ipaddr - command-line IP address manipulation tool
ipaddr [-M] ADDRESS [COMMAND
[ARGS...]] ...
ipaddr is a command-line tool for manipulating and querying
IP addresses and networks. It provides functionality similar to Python's
ipaddress module but as a standalone CLI utility.
Commands can be chained; chainable commands update the current
address for use by subsequent commands.
- -M
- Output prefix as netmask (e.g., /255.255.255.0 instead of /24).
- -h
- Display help message and exit.
- (none)
- Print normalized address.
- version
- Print IP version (4 or 6).
- packed
- Print address as hexadecimal bytes (no separators).
- to-int
- Print address as decimal integer.
- network
- Print network address with prefix.
- broadcast
- Print broadcast address. Requires address with prefix.
- num-addresses
- Print number of addresses in network.
- host
INDEX
- Print host at index (negative indices count from end).
- host-index
- Print index of address within its network.
- subnet PLEN
INDEX
- Print subnet. PLEN is prefix length (or +N for relative). INDEX may be
negative to count from end.
- super
PLEN
- Print supernet. PLEN is prefix length (or -N for relative).
Each returns exit code 0 if true, 1 if false.
- is-loopback
- Check if address is loopback.
- is-private
- Check if address is private (RFC 1918 for IPv4, ULA for IPv6).
- is-global
- Check if address is global unicast.
- is-multicast
- Check if address is multicast.
- is-link-local
- Check if address is link-local.
- is-unspecified
- Check if address is unspecified (0.0.0.0 or ::).
- is-reserved
- Check if address is reserved.
- zone-id
- Print IPv6 zone ID (interface name or number).
- scope-id
- Print IPv6 numeric scope ID.
- ipv4
- Extract IPv4 address from IPv6 (mapped, compatible) or pass through.
- 6to4
- Extract IPv4 address from 6to4 address.
- teredo
server|client
- Extract Teredo server or client IPv4 address.
Each takes an ADDRESS argument and returns exit code 0 if true, 1
if false.
- in ADDR
- Check if current network is contained in ADDR.
- contains
ADDR
- Check if current network contains ADDR.
- overlaps
ADDR
- Check if current network overlaps with ADDR.
- eq ADDR
- Check if equal to ADDR.
- ne ADDR
- Check if not equal to ADDR.
- lt ADDR
- Check if less than ADDR.
- le ADDR
- Check if less than or equal to ADDR.
- gt ADDR
- Check if greater than ADDR.
- ge ADDR
- Check if greater than or equal to ADDR.
- 0
- Success, or boolean true for is-* and comparison commands.
- 1
- Boolean false for is-* and comparison commands.
- 2
- Usage error or invalid input.
Normalize an IP address:
$ ipaddr 192.168.001.001
192.168.1.1
Get network address:
$ ipaddr 192.168.1.30/28 network
192.168.1.16/28
Chain commands to find a specific host in a subnet:
$ ipaddr 192.168.0.0/16 subnet 24 5 host 100
192.168.5.100
Check if an address is private:
$ ipaddr 10.0.0.1 is-private && echo "Private" || echo "Not private"
Private
Convert to decimal integer:
$ ipaddr 192.168.1.1 to-int
3232235777
Output with netmask notation:
$ ipaddr -M 192.168.1.0/24
192.168.1.0/255.255.255.0
Copyright © 2025 Eugene Kim. License: MIT.