1IPCALC(1) General Commands Manual IPCALC(1)
2
3
4
6 ipcalc - Perform simple operations on IP addresses and networks
7
9 ipcalc [OPTION]... IP address[/prefix] [netmask]
10
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
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
121 Display all information of an IPv4
122 ``` $ ipcalc --all-info 193.92.150.2/24 Address: 193.92.150.2 Network:
123 193.92.150.0/24 Netmask: 255.255.255.0 = 24 Broadcast: 193.92.150.255
124 Reverse DNS: 150.92.193.in-addr.arpa.
125
126 Address space: Internet Address class: Class C HostMin: 193.92.150.1
127 HostMax: 193.92.150.254 Hosts/Net: 254
128
129 Country code: GR Country: Greece ```
130
131 Display information in key-value format
132 $ ipcalc -pnmb --minaddr --maxaddr --geoinfo --addrspace
133 193.92.150.2/255.255.255.224 NETMASK=255.255.255.224 PREFIX=27 BROAD‐
134 CAST=193.92.150.31 NETWORK=193.92.150.0 MINADDR=193.92.150.1 MAX‐
135 ADDR=193.92.150.30 ADDRSPACE="Internet" COUNTRY="Greece"
136
137 Display all information of an IPv6
138 ``` $ ipcalc --all-info 2a03:2880:20:4f06:face:b00c:0:14/64 Full Ad‐
139 dress: 2a03:2880:0020:4f06:face:b00c:0000:0014 Address:
140 2a03:2880:20:4f06:face:b00c:0:14 Full Network:
141 2a03:2880:0020:4f06:0000:0000:0000:0000/64 Network:
142 2a03:2880:20:4f06::/64 Netmask: ffff:ffff:ffff:ffff:: = 64 Reverse DNS:
143 6.0.f.4.0.2.0.0.0.8.8.2.3.0.a.2.ip6.arpa.
144
145 Address space: Global Unicast HostMin: 2a03:2880:20:4f06:: HostMax:
146 2a03:2880:20:4f06:ffff:ffff:ffff:ffff Hosts/Net: 2^(64) =
147 18446744073709551616
148
149 Country code: IE Country: Ireland ```
150
151 Display JSON output
152 $ ipcalc --all-info -j 2a03:2880:20:4f06:face:b00c:0:14/64 { "FULLAD‐
153 DRESS":"2a03:2880:0020:4f06:face:b00c:0000:0014", "AD‐
154 DRESS":"2a03:2880:20:4f06:face:b00c:0:14", "FULLNET‐
155 WORK":"2a03:2880:0020:4f06:0000:0000:0000:0000", "NET‐
156 WORK":"2a03:2880:20:4f06::", "NETMASK":"ffff:ffff:ffff:ffff::", "PRE‐
157 FIX":"64", "REVERSEDNS":"6.0.f.4.0.2.0.0.0.8.8.2.3.0.a.2.ip6.arpa.",
158 "ADDRSPACE":"Global Unicast", "MINADDR":"2a03:2880:20:4f06::", "MAX‐
159 ADDR":"2a03:2880:20:4f06:ffff:ffff:ffff:ffff", "AD‐
160 DRESSES":"18446744073709551616", "COUNTRYCODE":"IE", "COUNTRY":"Ire‐
161 land", "COORDINATES":"53.000000,-8.000000" }
162
163 Lookup of a hostname
164 $ ipcalc --lookup-host localhost --no-decorate ::1
165
166 IPv4 lookup of a hostname
167 $ ipcalc --lookup-host localhost --no-decorate -4 127.0.0.1
168
169 Reverse lookup of a hostname
170 $ ipcalc -h 127.0.0.1 --no-decorate localhost
171
173 Nikos Mavrogiannopoulos <nmav@redhat.com> Erik Troan <ewt@redhat.com>
174 Preston Brown <pbrown@redhat.com> David Cantrell <dcantrell@redhat.com>
175
177 Report bugs at https://gitlab.com/ipcalc/ipcalc/issues
178
180 Copyright © 1997-2020 Red Hat, Inc. This is free software; see the
181 source for copying conditions. There is NO warranty; not even for MER‐
182 CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
183
184
185
186 October 2020 IPCALC(1)