Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
IPADDR(1)			 User Commands			     IPADDR(1)

NAME
       ipaddr -	command-line IP	address	manipulation tool

SYNOPSIS
       ipaddr [-M] ADDRESS [COMMAND [ARGS...]] ...

DESCRIPTION
       ipaddr  is  a  command-line  tool  for manipulating and querying	IP ad-
       dresses 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.

OPTIONS
       -M     Output prefix as netmask (e.g., /255.255.255.0 instead of	/24).

       -h     Display help message and exit.

COMMANDS
   Basic Commands
       (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.

   Prefix/Mask Commands
       prefix-length, prefixlen
	      Print prefix length.

       netmask
	      Print network mask.

       hostmask
	      Print host mask (inverse of netmask).

       address
	      Print address without prefix.

   Network Commands
       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).

   Classification Commands
       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.

   IPv6-Specific Commands
       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.

   Comparison Commands
       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.

EXIT STATUS
       0      Success, or boolean true for is-*	and comparison commands.

       1      Boolean false for	is-* and comparison commands.

       2      Usage error or invalid input.

EXAMPLES
       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

SEE ALSO
       ipcalc(1), sipcalc(1)

AUTHOR
       Eugene Kim

COPYRIGHT
       Copyright (C) 2025 Eugene Kim. License: MIT.

ipaddr 1.0.0			 January 2025			     IPADDR(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=ipaddr&sektion=1&manpath=FreeBSD+Ports+15.1.quarterly>

home | help