1IPCALC(1)                   General Commands Manual                  IPCALC(1)
2
3
4

NAME

6       ipcalc - Perform simple operations on IP addresses and networks
7

SYNOPSIS

9       ipcalc [OPTION]... IP address[/prefix] [netmask]
10

Description

12       ipcalc  provides a simple way to calculate IP information for a host or
13       network. Depending on the options specified, it may be used to  provide
14       IP  network  information in human readable format, in a format suitable
15       for parsing in scripts, generate random private addresses,  resolve  an
16       IP address, or check the validity of an address.
17
18       By  default  or  when the --info or --all-info parameters are specified
19       the information provided is free form and human readable. Otherwise the
20       output is JSON formatted when -j is specified, or when specific options
21       are given (e.g., --prefix) the output is in the VAR=VALUE format.
22
23       The various options specify what information ipcalc should  display  on
24       standard  output.  Multiple options may be specified. It is required to
25       specify an IP address; several operations require a netmask or  a  CIDR
26       prefix as well.
27

Options

29-c, --check Validate the IP address under the specified family.
30
31-i,  --info  Display generic information on the provided network in
32           human readable format. This is the default option if no  other  op‐
33           tions are provided.
34
35--all-info  Display verbose information on the provided network and
36           addresses in human readable format. That  includes  GeoIP  informa‐
37           tion.
38
39-S,  --split  Split the provided network using the specified prefix
40           or netmask. That is, split up the network into smaller chunks of  a
41           specified  prefix.  When combined with no-decorate mode (--no-deco‐
42           rate), the split networks will be printed in raw form. Example "ip‐
43           calc -S 26 192.168.1.0/24".
44
45-d, --deaggregate Deaggregates the provided address range. That is,
46           print the networks that cover the range. The range is  given  using
47           the  ´-´ separator, e.g., "192.168.1.3-192.168.1.23". When combined
48           with no-decorate mode (--no-decorate), the networks are printed  in
49           raw form.
50
51-r,  --random-private  Generate  a random private address using the
52           supplied prefix or mask. By default it  displays  output  in  human
53           readable  format,  but  may  be  combined with other options (e.g.,
54           --network) to display specific information in VAR=VALUE format.
55
56-h, --hostname Display the hostname for the given IP  address.  The
57           variable exposed is HOSTNAME.
58
59-o,  --lookup-host  Display  the IP address for the given hostname.
60           The variable exposed is ADDRESS.
61
62-4, --ipv4 Explicitly specify the IPv4 address family.
63
64-6, --ipv6 Explicitly specify the IPv6 address family.
65
66-b, --broadcast Display the broadcast address for the given IP  ad‐
67           dress  and  netmask.  The  variable exposed is BROADCAST (if avail‐
68           able).
69
70-a, --address Display the IP address for the given input. The vari‐
71           able exposed is ADDRESS (if available).
72
73-g,  --geoinfo  Display geographic information for the given IP ad‐
74           dress. This option requires libGeoIP/libmaxminddb to be  available.
75           The  variables  exposed  are COUNTRYCODE, COUNTRY, CITY and COORDI‐
76           NATES (when available).
77
78-m, --netmask Calculate the netmask for the given IP address. If no
79           mask  or  prefix  is  provided,  in IPv6 a 128-bit mask is assumed,
80           while in IPv4 it assumes that the IP address is in a complete class
81           A, B, or C network. Note, however, that many networks no longer use
82           the default netmasks in IPv4. The variable exposed is NETMASK.
83
84-p, --prefix Show the prefix for the  given  mask/IP  address.  The
85           variable exposed is PREFIX.
86
87--class-prefix  Assign  the  netmask  of  the provided IPv4 address
88           based on the address class. This was the default in  previous  ver‐
89           sions of this software.
90
91-n,  --network Display the network address for the given IP address
92           and netmask. The variable exposed is NETWORK.
93
94--reverse-dns Display the reverse DNS for the given IP address  and
95           netmask. The variable exposed is REVERSEDNS.
96
97--minaddr Display the minimum host address in the provided network.
98           The variable exposed is MINADDR.
99
100--maxaddr Display the maximum host address in the provided network.
101           The variable exposed is MAXADDR.
102
103--addresses  Display  the  number of host addresses in the provided
104           network. The variable exposed is ADDRESSES.
105
106--addrspace Display address space allocation  information  for  the
107           provided network. The variable exposed is ADDRSPACE.
108
109--no-decorate  Print only the requested information. That when com‐
110           bined with split networks option,  will  only  print  the  networks
111           without any additions for readability.
112
113-j, --json When used with -i or -S, print the info as a JSON object
114           instead of the usual output format.
115
116-s, --silent Don´t ever display error messages.
117
118
119

Examples

121   Display all information of an IPv4
122       $ ipcalc --all-info 193.92.150.2/24
123       Address:        193.92.150.2
124       Network:        193.92.150.0/24
125       Netmask:        255.255.255.0 = 24
126       Broadcast:      193.92.150.255
127       Reverse DNS:    150.92.193.in-addr.arpa.
128
129       Address space:  Internet
130       Address class:  Class C
131       HostMin:        193.92.150.1
132       HostMax:        193.92.150.254
133       Hosts/Net:      254
134
135       Country code:   GR
136       Country:        Greece
137
138   Display information in key-value format
139       $ ipcalc -pnmb --minaddr --maxaddr --geoinfo --addrspace 193.92.150.2/255.255.255.224
140       NETMASK=255.255.255.224
141       PREFIX=27
142       BROADCAST=193.92.150.31
143       NETWORK=193.92.150.0
144       MINADDR=193.92.150.1
145       MAXADDR=193.92.150.30
146       ADDRSPACE="Internet"
147       COUNTRY="Greece"
148
149   Display all information of an IPv6
150       $ ipcalc --all-info 2a03:2880:20:4f06:face:b00c:0:14/64
151       Full Address:   2a03:2880:0020:4f06:face:b00c:0000:0014
152       Address:        2a03:2880:20:4f06:face:b00c:0:14
153       Full Network:   2a03:2880:0020:4f06:0000:0000:0000:0000/64
154       Network:        2a03:2880:20:4f06::/64
155       Netmask:        ffff:ffff:ffff:ffff:: = 64
156       Reverse DNS:    6.0.f.4.0.2.0.0.0.8.8.2.3.0.a.2.ip6.arpa.
157
158       Address space:  Global Unicast
159       HostMin:        2a03:2880:20:4f06::
160       HostMax:        2a03:2880:20:4f06:ffff:ffff:ffff:ffff
161       Hosts/Net:      2^(64) = 18446744073709551616
162
163       Country code:   IE
164       Country:        Ireland
165
166   Display JSON output
167       $ ipcalc --all-info -j 2a03:2880:20:4f06:face:b00c:0:14/64
168       {
169         "FULLADDRESS":"2a03:2880:0020:4f06:face:b00c:0000:0014",
170         "ADDRESS":"2a03:2880:20:4f06:face:b00c:0:14",
171         "FULLNETWORK":"2a03:2880:0020:4f06:0000:0000:0000:0000",
172         "NETWORK":"2a03:2880:20:4f06::",
173         "NETMASK":"ffff:ffff:ffff:ffff::",
174         "PREFIX":"64",
175         "REVERSEDNS":"6.0.f.4.0.2.0.0.0.8.8.2.3.0.a.2.ip6.arpa.",
176         "ADDRSPACE":"Global Unicast",
177         "MINADDR":"2a03:2880:20:4f06::",
178         "MAXADDR":"2a03:2880:20:4f06:ffff:ffff:ffff:ffff",
179         "ADDRESSES":"18446744073709551616",
180         "COUNTRYCODE":"IE",
181         "COUNTRY":"Ireland",
182         "COORDINATES":"53.000000,-8.000000"
183       }
184
185   Lookup of a hostname
186       $ ipcalc --lookup-host localhost --no-decorate
187       ::1
188
189   IPv4 lookup of a hostname
190       $ ipcalc --lookup-host localhost --no-decorate -4
191       127.0.0.1
192
193   Reverse lookup of a hostname
194       $ ipcalc -h 127.0.0.1 --no-decorate
195       localhost
196

Authors

198       ○   Nikos Mavrogiannopoulos n.mavrogiannopoulos@gmail.com
199
200       ○   Erik Troan ewt@redhat.com
201
202       ○   Preston Brown pbrown@redhat.com
203
204       ○   David Cantrell dcantrell@redhat.com
205
206
207

Reporting Bugs

209       Report bugs at https://gitlab.com/ipcalc/ipcalc/issues
210
212       Copyright © 1997-2020 Red Hat, Inc. This  is  free  software;  see  the
213       source  for copying conditions. There is NO warranty; not even for MER‐
214       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
215
216
217
218                                   June 2023                         IPCALC(1)
Impressum