IPCALC

Section: User Commands (1)
Updated: Oct 1 2018
Page Index
 

NAME

ipcalc - perform simple operations on IP addresses and networks  

SYNOPSIS

ipcalc [OPTION]... <IP address>[/prefix] [netmask]

 

DESCRIPTION

ipcalc provides a simple way to calculate IP information for a host or network. Depending on the options specified, it may be used to provide IP network information in human readable format, in a format suitable for parsing in scripts, generate random private addresses, resolve an IP address, or check the validity of an address.

By default or when the --info or --all-info parameters are specified the information provided is free form and human readable. Otherwise, when specific options are given (e.g., --prefix) the output is in the VAR=VALUE format.

The various options specify what information ipcalc should display on standard output. Multiple options may be specified. It is required to specify an IP address; several operations require a netmask or a CIDR prefix as well.

 

OPTIONS

-c, --check
Validate the IP address under the specified family.

-i, --info
Display generic information on the provided network in human readable format. This is the default option if no other options are provided.

--all-info
Display verbose information on the provided network and addresses in human readable format. That includes GeoIP information.

-S, --split
Split the provided network using the specified prefix or netmask. That is, split up the network into smaller chunks of a specified prefix. When combined with no-decorate mode (--no-decorate), the split networks will be printed in raw form. Example "ipcalc -S 26 192.168.1.0/24".

-d, --deaggregate
Deaggregates the provided address range. That is, print the networks that cover the range. The range is given using the '-' separator, e.g., "192.168.1.3-192.168.1.23". When combined with no-decorate mode (--no-decorate), the networks are printed in raw form.

-r, --random-private
Generate a random private address using the supplied prefix or mask. By default it displays output in human readable format, but may be combined with other options (e.g., --network) to display specific information in VAR=VALUE format.

-h, --hostname
Display the hostname for the given IP address. The variable exposed is HOSTNAME.

-o, --lookup-host
Display the IP address for the given hostname. The variable exposed is ADDRESS.

-4, --ipv4
Explicitly specify the IPv4 address family.

-6, --ipv6
Explicitly specify the IPv6 address family.

-b, --broadcast
Display the broadcast address for the given IP address and netmask. The variable exposed is BROADCAST (if available).

-a, --address
Display the IP address for the given input. The variable exposed is ADDRESS (if available).

-g, --geoinfo
Display geographic information for the given IP address. This option requires libGeoIP/libmaxminddb to be available. The variables exposed are COUNTRYCODE, COUNTRY, CITY and COORDINATES (when available).

-m, --netmask
Calculate the netmask for the given IP address. If no mask or prefix is provided, in IPv6 a 128-bit mask is assumed, while in IPv4 it assumes that the IP address is in a complete class A, B, or C network. Note, however, that many networks no longer use the default netmasks in IPv4. The variable exposed is NETMASK.

-p, --prefix
Show the prefix for the given mask/IP address. The variable exposed is PREFIX.

  --class-prefix
Assign the netmask of the provided IPv4 address based on the address class. This was the default in previous versions of this software.

-n, --network
Display the network address for the given IP address and netmask. The variable exposed is NETWORK.

  --reverse-dns
Display the reverse DNS for the given IP address and netmask. The variable exposed is REVERSEDNS.

  --minaddr
Display the minimum host address in the provided network. The variable exposed is MINADDR.

  --maxaddr
Display the maximum host address in the provided network. The variable exposed is MAXADDR.

  --addresses
Display the number of host addresses in the provided network. The variable exposed is ADDRESSES.

  --addrspace
Display address space allocation information for the provided network. The variable exposed is ADDRSPACE.

  --no-decorate
Print only the requested information. That when combined with split networks option, will only print the networks without any additions for readability.

-j, --json
When used with -i or -S, print the info as a JSON object instead of the usual output format.

-s, --silent
Don't ever display error messages.

 

AUTHORS

Nikos Mavrogiannopoulos <nmav@redhat.com>
Erik Troan <ewt@redhat.com>
Preston Brown <pbrown@redhat.com>
David Cantrell <dcantrell@redhat.com>


 

REPORTING BUGS

Report bugs at https://gitlab.com/ipcalc/ipcalc/issues  

COPYRIGHT

Copyright © 1997-2018 Red Hat, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
DESCRIPTION
OPTIONS
AUTHORS
REPORTING BUGS
COPYRIGHT