IPCALC(1)
π NAME π
ipcalc β do lil operations on IP addresses and networks, bestie π
β¨ SYNOPSIS β¨
ipcalc [OPTION]... IP address[/prefix] [netmask]
πΈ DESCRIPTION πΈ
okay so ipcalc is literally your group-chat bestie for figuring out IP info for a host or a whole network. depending on which options you pass, it can hand you IP network info in human readable format (so you can actually read it, no cap), in a format that's built for scripts to parse, generate random private addresses, resolve an IP address, or vibe-check whether an address is even valid. β¨
the options decide what ipcalc prints: by default, or with --info or --all-info, you get a summary of the network; with specific info options (like --prefix), you get only those values. the --format option picks how it gets printed, which is fully explained in the Output format section. Multiple options may be specified. And you must give an IP address β several operations need a netmask or a CIDR prefix too, so don't ghost them. π«Ά
π OUTPUT FORMAT π
the --format=FORMAT option picks one of these, and they're all iconic in their own way:
humanβ Titled lines, as in the summary. Colors are used only when the output is a terminal and theNO_COLORenvironment variable is not set. This is the default for the summary and for--split,--split-hosts,--deaggregateand--binary. πshellβVAR=VALUElines that can be passed to the shell'seval; a value that contains characters special to the shell, such as a space, is quoted and escaped. This is the default for the specific info options. πjsonβ A JSON object, whose values are all strings or arrays of strings. π§valueβ The values only, one per line; a value that would be quoted in the shell format keeps its quotes. periodt.
Each format applies to whatever is selected: the summary, or exactly the values of the specific info options, e.g., ipcalc --format=json -n -m 192.168.1.5/24 prints only NETWORK and NETMASK. The specific info options accept all four formats; the formats each operation accepts are given in its description.
bestie listen π Scripts should always pass --format, so that their output does not depend on the defaults. don't be out here rawdogging the defaults in prod fr fr π
π OPTIONS π
-c,--checkβ Checks whether this is a valid IP address. When an IP family is specified only the addresses of that family are accepted. A zero exit status indicates a well formed address and a non-zero exit status indicates a malformed address.--formatis ignored. (yes you can use this to gatekeep bad addresses π)--equals=NET,--subnet-of=NET,--overlaps=NETβ Compare the provided network with NET and print the result, such asThe networks overlapor192.168.0.0/24 is a subnet of 192.168.0.0/23; nothing is printed with--silent.--equalsholds if both have the same network address and prefix,--subnet-ofif every address of the network is in NET (equal networks included), and--overlapsif the two share at least one address; for CIDR networks the latter holds exactly when one is a subnet of the other. Host bits are ignored, and NET is given in the same form as the provided address, with an optional prefix or netmask after a slash. Networks of different families never compare true. The exit status is0when the comparison holds,1when it does not, and2on any error, such as a malformed address. Only one comparison may be given, and not together with--check. The only format accepted ishuman. Exampleipcalc 192.168.0.1/24 --subnet-of=192.168.0.0/23. π₯-i,--infoβ Display basic information on the provided network in human readable format, in a short summary, plus the fields of any specific info options given (e.g.,--reverse-dns). This is the default option if no other options are provided. The formats accepted arehuman,shellandjson; with--format, the specific info options other than--lookup-hostcannot be given. β¨--all-infoβ Display all the informationipcalccan determine on the provided network and addresses in human readable format, which may be long. That includes geographic information, but not the hostname, which requires a DNS lookup (see--hostname). The formats accepted are as for--info. it's giving "tell me everything" energy π
For an IPv6 unicast address it also prints the interface identifier, i.e., the low 64 bits of the address, unless they are all zero or the address lies in ::/3. When the interface identifier is a Modified EUI-64 (it contains ff:fe in its middle octets), it prints the EUI-64, the MAC address it was derived from, whether that MAC address is universally (UAA) or locally (LAA) administered (MAC scope: universal or local), and whether it is an individual or group address (MAC type). These fields are not derived from other interface identifiers, such as stable privacy or temporary addresses, whose bits carry no such meaning (RFC 7136). π¦
-S,--split=[COUNT:]PREFIXβ Split the provided network using the specified prefix or netmask. That is, split up the network into smaller chunks of a specified prefix. The formats accepted arehuman,jsonandvalue; withvalue, only the split networks are printed, one per line. Example:
ipcalc -S 26 192.168.1.0/24
The option can be repeated to split the network into subnets of different sizes, also known as a VLSM (variable-length subnet mask) split. Each request of the form COUNT:PREFIX asks for COUNT subnets of the given prefix or netmask, and at most one request without a count takes all the space that remains. Requests are allocated from the start of the network, the largest subnets first, while the subnets are printed in the order of the requests. Space that is not allocated to any request is printed as unused networks, except with --format=value. If the network is too small for the requests, nothing is printed and the exit status is 1. Example:
ipcalc -S 1:58 -S 64 2001:db8:1c88:6000::/56
--split-hosts=N1,N2,...β Split the provided network into subnets that hold N1, N2, ... hosts, one subnet for each count. Each subnet is the smallest that holds the hosts; for IPv4 that includes the network and broadcast addresses (e.g., 10 hosts need a/28). The subnets are allocated as with--splitand printed with their details, followed by the needed size, the used network and the unused networks. The values are those of the split of the Debianipcalc(its-soption), except that IPv6 networks are supported, a host count of0is rejected, and if the network is too small for the requests, nothing is printed and the exit status is1. It cannot be combined with--split. The formats accepted are as for--split. Example:
ipcalc --split-hosts=10,20,30 192.168.0.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. The formats accepted arehuman,jsonandvalue; withvalue, only the networks are printed, one per line. π--binaryβ Displays the bits of the provided address or, when a prefix is given, the bits of the network part of the network; any host bits set in the address are ignored. By default it prints each octet of an IPv4 address, or each 16-bit group of an IPv6 address, above its bits, marks the host bits withx, and brackets the network and host parts with UTF-8 box-drawing characters. An IPv6 address is printed in two halves, or on a single line when the output is at least135columns wide (seeCOLUMNS). All four formats are accepted; withvalue, only the bits of the network are printed, as inNETWORK, e.g.,11000000101010000000000000000000for192.168.0.0/16. The variables exposed are the addresses of the output, each as all of its bits:ADDRESSwhen no prefix shorter than the address is given; otherwisePREFIXfollowed, for IPv4, byADDRESS,NETMASK,NETWORK,HOSTMIN,HOSTMAXandBROADCAST(for a/31, withoutNETWORKandBROADCAST), and for IPv6 byNETWORK. The bits are not part of the summary, and the option cannot be combined with other operations or with the specific info options. π-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 inVAR=VALUEformat. π²-h,--hostnameβ Display the hostname for the given IP address. The address must be a single address; a network (e.g.,127.0.0.1/8) is rejected. The variable exposed isHOSTNAME. π-o,--lookup-host=NAMEβ Display the IP address for the given hostname. With--infoor--all-info, display the summary of that address instead. The variable exposed isADDRESS. π«Ά-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 isBROADCAST(if available). π£-a,--addressβ Display the IP address for the given input. The variable exposed isADDRESS(if available). π
-g,--geoinfoβ bestie this one is the β¨geographyβ¨ option, it shows you geographic info for the IP address you handed over. Heads up though: it needslibmaxminddbto exist on your system, and ifipcalcwas built without it, it just won't accept this flag, periodt. The variables it exposes areCONTINENT,COUNTRYCODE,COUNTRY,CITY,POSTALCODE,COORDINATES(latitude,longitude),ACCURACYRADIUS,TIMEZONE(likeEurope/Athens),ASN,ASORG,ASNETWORKandGEONETWORK(when it's available). SoASNis the number of the autonomous system that routes the address on the Internet β think the network of one single operator, like an ISP, a hosting provider or a company β andASORGis the name of the org running it (e.g.,ASN=1241andASORG=Forthnet; those show up as "Routed by AS" and "Operated by" in the summary). They come from the GeoLite2 ASN database, when it's installed.ASNETWORKis the network, in CIDR notation, that the database holds them for; and since that database is built from routing data, it approximates the network the autonomous system announces β e.g., the allocation of the ISP that your address belongs to.GEONETWORKis the network, in CIDR notation, the database holds the printed values for. When the database has no country for the address,COUNTRYandCOUNTRYCODEbecome the country its users represent (like, say, a military base π«‘) or, if there isn't one of those either, the country where the network is registered.ACCURACYRADIUSis how accurateCOORDINATESare β a radius in kilometers around them where the address is likely to be. The summary prints it with its unit, e.g.,"Accuracy: 200 km". And for a network? A value only gets printed when the database knows it for the whole network, not just for the address you gave. no cap.-m,--netmaskβ calculates the netmask for the IP address. If you don't provide a mask or prefix, IPv6 assumes a 128-bit mask, while IPv4 assumes your IP lives in a complete class A, B, or C network. β οΈ But listen β so many networks don't use the default IPv4 netmasks anymore, so don't get too comfy with that assumption. The variable exposed isNETMASK.--wildcardβ shows the wildcard mask, aka the inverse of the netmask, the thing Cisco ACLs and OSPF vibe with, e.g.,"0.0.0.255"for a/24network. It's IPv4-only bestie, nothing prints for IPv6. Variable exposed isWILDCARD. The summary shows it when you pass--all-info.-p,--prefixβ shows the prefix for the mask/IP address. Variable exposed isPREFIX.--class-prefixβ assigns the netmask of the given IPv4 address based on the address class. This was literally the default in previous versions of this software, iykyk.-n,--networkβ shows the network address for your IP address and netmask. Variable exposed isNETWORK.--cidrβ shows the network address and the prefix in CIDR notation, e.g.,"192.168.123.0/24". The prefix is included for a single address too, slay. Variable exposed isCIDR. For example,ipcalc -r 24 --cidr --format=valueprints a random private network. π--reverse-dnsβ shows the reverse DNS for the given IP address and netmask. Now here's the tea: reverse DNS domains for IPv6 (RFC 3596) can only be delegated at 4-bit boundaries, so for an IPv6 prefix that is not a multiple of 4, the network is covered by up to 8 domains, and all of them get printed. In that case theREVERSEDNSvariable holds a quoted, space-separated list, and with--format=valueeach domain prints on its own line. The summary shows it with--all-info, and in JSONREVERSEDNSis always an array. Variable exposed isREVERSEDNS.--minaddrβ shows the minimum host address in the provided network. Variable exposed isMINADDR.--maxaddrβ shows the maximum host address in the provided network. Variable exposed isMAXADDR.--addressesβ shows the number of host addresses in the provided network. Variable exposed isADDRESSES.--addrspaceβ shows address space allocation info for the provided network. Variable exposed isADDRSPACE.--format=FORMATβ prints the output ashuman,shell,jsonorvalue; peek the Output format section for the deets. π-s,--silentβ never ever displays error messages, and never shows the result of a comparison. π€«
π Deprecated options π
These are kept around for compatibility with earlier versions. On a terminal, ipcalc prints a little hint that names the replacement, so you're not left guessing. π«Ά
-j,--jsonβ prints the summary as a JSON object, even when specific info options are given, which only add their values to it; with--split,--split-hosts,--deaggregateand--binaryit prints JSON, and with the comparison options it prints nothing. Use--format=jsoninstead β that prints only the selected values. β¨--no-decorateβ prints the values of the specific info options, or the networks of--split,--split-hostsand--deaggregate, without titles; prints the summary without colors; and with the comparison options prints nothing. It's ignored when-jis given, and it can't be used with--binary. Use--format=valueinstead, or for the summary use--format=humanwith theNO_COLORenvironment variable set.
π Environment π
NO_COLORβ when it's set, to any value, the human format prints without colors, even on a terminal. bye bye rainbows πCOLUMNSβ the width of the output in columns. With--binary, an IPv6 address prints on a single line when it's135or more, and in two halves otherwise, e.g.,"COLUMNS=135 ipcalc --binary 2001:db8::/48". When it's unset, the width of the terminal is used, or80when the output isn't a terminal. π
πΈ EXAMPLES πΈ (aka the part where it all clicks, bestie)
π« Display all information of an IPv4
$ ipcalc --all-info 193.92.150.2/24
Address: 193.92.150.2
Network: 193.92.150.0/24
Netmask: 255.255.255.0 = 24
Wildcard: 0.0.0.255
Broadcast: 193.92.150.255
Reverse DNS: 150.92.193.in-addr.arpa.
Address space: Internet
Address class: Class C
HostMin: 193.92.150.1
HostMax: 193.92.150.254
Hosts/Net: 254
Country code: GR
Country: Greece
Look at that. Everything. Network, netmask, wildcard, broadcast, reverse DNS, address space, class, host range, host count, and even the country. It's giving full dossier. π΅οΈβοΈ
π« Display information in key-value format
$ ipcalc --format=shell -pnmb --minaddr --maxaddr --geoinfo --addrspace 193.92.150.2/255.255.255.224
NETWORK=193.92.150.0
NETMASK=255.255.255.224
PREFIX=27
BROADCAST=193.92.150.31
ADDRSPACE=Internet
MINADDR=193.92.150.1
MAXADDR=193.92.150.30
COUNTRYCODE=GR
COUNTRY=Greece
This is the "pls just hand me variables so I can eval you" format and honestly it ate. β¨
π« Display all information of an IPv6
$ ipcalc --all-info 2a03:2880:20:4f06:face:b00c:0:14/64
Full Address: 2a03:2880:0020:4f06:face:b00c:0000:0014
Address: 2a03:2880:20:4f06:face:b00c:0:14
Full Network: 2a03:2880:0020:4f06:0000:0000:0000:0000/64
Network: 2a03:2880:20:4f06::/64
Netmask: ffff:ffff:ffff:ffff:: = 64
Reverse DNS: 6.0.f.4.0.2.0.0.0.8.8.2.3.0.a.2.ip6.arpa.
Address space: Global Unicast
Interface ID: face:b00c:0000:0014
HostMin: 2a03:2880:20:4f06::
HostMax: 2a03:2880:20:4f06:ffff:ffff:ffff:ffff
Hosts/Net: 2^(64) = 18446744073709551616
Country code: IE
Country: Ireland
Sixteen quintillion hosts in one net, no big deal. And note that Hosts/Net shows you the math too β 2^(64) = 18446744073709551616 β because we don't gatekeep. π
π« Display the MAC address behind an IPv6 link-local address
$ ipcalc --all-info fe80::21b:21ff:fe3a:5c7d/64
Full Address: fe80:0000:0000:0000:021b:21ff:fe3a:5c7d
Address: fe80::21b:21ff:fe3a:5c7d
Full Network: fe80:0000:0000:0000:0000:0000:0000:0000/64
Network: fe80::/64
Netmask: ffff:ffff:ffff:ffff:: = 64
Reverse DNS: 0.0.0.0.0.0.0.0.0.0.0.0.0.8.e.f.ip6.arpa.
Address space: Link-Scoped Unicast
Interface ID: 021b:21ff:fe3a:5c7d
EUI-64: 00:1b:21:ff:fe:3a:5c:7d
MAC address: 00:1b:21:3a:5c:7d
MAC scope: universal
MAC type: individual
HostMin: fe80::
HostMax: fe80::ffff:ffff:ffff:ffff
Hosts/Net: 2^(64) = 18446744073709551616
Not it un-embedding a whole MAC address out of the interface ID like that π The EUI-64 line, the MAC address, the scope, the type β all just there. Main character energy, fr fr.
π« Display JSON output
$ ipcalc --all-info --format=json 2a03:2880:20:4f06:face:b00c:0:14/64
{
"FULLADDRESS":"2a03:2880:0020:4f06:face:b00c:0000:0014",
"ADDRESS":"2a03:2880:20:4f06:face:b00c:0:14",
"FULLNETWORK":"2a03:2880:0020:4f06:0000:0000:0000:0000",
"NETWORK":"2a03:2880:20:4f06::",
"NETMASK":"ffff:ffff:ffff:ffff::",
"PREFIX":"64",
"CIDR":"2a03:2880:20:4f06::/64",
"REVERSEDNS":[
"6.0.f.4.0.2.0.0.0.8.8.2.3.0.a.2.ip6.arpa."],
"ADDRSPACE":"Global Unicast",
"INTERFACEID":"face:b00c:0000:0014",
"MINADDR":"2a03:2880:20:4f06::",
"MAXADDR":"2a03:2880:20:4f06:ffff:ffff:ffff:ffff",
"ADDRESSES":"18446744073709551616",
"COUNTRYCODE":"IE",
"COUNTRY":"Ireland",
"COORDINATES":"53.000000,-8.000000"
}
For when your script needs structured data and not vibes. (Tho we contain multitudes β we can do both.) π«Ά
π« Split a network into subnets of different sizes
$ ipcalc -S 1:28 -S 2:27 192.168.0.0/24
[Split networks]
Network: 192.168.0.64/28
Network: 192.168.0.0/27
Network: 192.168.0.32/27
Total: 3
[Unused networks]
Network: 192.168.0.80/28
Network: 192.168.0.96/27
Network: 192.168.0.128/25
Bestie it even tells you the unused networks. Nothing left on read. π
π« Split a network into subnets for a number of hosts
$ ipcalc --split-hosts=10,20 192.168.0.0/24
[Split networks]
1. Requested size: 10 hosts
Network: 192.168.0.32/28
Netmask: 255.255.255.240 = 28
Broadcast: 192.168.0.47
HostMin: 192.168.0.33
HostMax: 192.168.0.46
Hosts/Net: 14
2. Requested size: 20 hosts
Network: 192.168.0.0/27
Netmask: 255.255.255.224 = 27
Broadcast: 192.168.0.31
HostMin: 192.168.0.1
HostMax: 192.168.0.30
Hosts/Net: 30
Total: 2
Needed size: 48
Used network: 192.168.0.0/26
[Unused networks]
Network: 192.168.0.48/28
Network: 192.168.0.64/26
Network: 192.168.0.128/25
You asked for hosts, it gave you hosts, and it also told you the Needed size, the Used network, and what's still free. Generous queen. π
π« Split an IPv6 prefix into one /58 and /64 networks in the remaining space
$ ipcalc --format=value -S 1:58 -S 64 2001:db8:1c88:6000::/56
2001:db8:1c88:6000::/58
2001:db8:1c88:6040::/64
2001:db8:1c88:6041::/64
...
2001:db8:1c88:60ff::/64
Yes queen, carve up that IPv6 space. π¦
π« Display the bits of a network
$ ipcalc --binary 192.168.92.6/22
Network: 192.168.92.0/22
192. 168. 92-95. 0-255
11000000.10101000.010111xx.xxxxxxxx
βββββ network /22 βββββββ host 10 β
Address: 192.168.92.6 11000000.10101000.01011100.00000110
Netmask: 255.255.252.0 11111111.11111111.11111100.00000000
Network: 192.168.92.0 11000000.10101000.01011100.00000000
HostMin: 192.168.92.1 11000000.10101000.01011100.00000001
HostMax: 192.168.95.254 11000000.10101000.01011111.11111110
Broadcast: 192.168.95.255 11000000.10101000.01011111.11111111
Not the xxs showing you exactly which bits are host bits π this is the visual you show your group chat when someone asks "wait what even IS a /22". Iconic.
π« Check whether a network is a subnet of another
$ ipcalc 192.168.0.1/24 --subnet-of=192.168.1.15/23
192.168.0.0/24 is a subnet of 192.168.0.0/23
Short. Direct. Answered in one line. π
π« Check whether a network overlaps any network in a list
$ while read net; do
> ipcalc -s 10.20.0.0/16 --overlaps="$net"
> case $? in 0) echo "conflict: $net" ;; 2) echo "bad entry: $net" ;; esac
> done < networks.txt
This is THE vibe-check-the-whole-firewall-ruleset move. 0 means conflict, 2 means bad entry, and you get a whole audit loop in four lines. π₯
π« Lookup of a hostname
$ ipcalc --format=value --lookup-host localhost
::1
π« IPv4 lookup of a hostname
$ ipcalc --format=value --lookup-host localhost -4
127.0.0.1
π« Reverse lookup of a hostname
$ ipcalc --format=value -h 127.0.0.1
localhost
Forward and reverse, both directions, both protocols. Obsessed. π
π« Use the values in a shell script
$ eval "$(ipcalc --format=shell -n -p 192.168.1.5/24)"
$ echo "$NETWORK/$PREFIX"
192.168.1.0/24
The eval + --format=shell combo is the whole hack. It just works. π
π AUTHORS π
- Nikos Mavrogiannopoulos
n.mavrogiannopoulos@gmail.com - Erik Troan
ewt@redhat.com - Preston Brown
pbrown@redhat.com - David Cantrell
dcantrell@redhat.com
The legends who built the thing. Respect. π«‘
π REPORTING BUGS π
Found a bug? Report it at <https://gitlab.com/ipcalc/ipcalc/issues> β that's the spot. Fr fr, they wanna know. π
π COPYRIGHT π
Copyright Β© 1997-2024 Red Hat, Inc. Copyright Β© 2020-2024 Nikos Mavrogiannopoulos. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Say it with me: NO warranty. Not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It's free software, bestie, not a promise. π
And that's the whole page, bestie!! πβ¨ This one's IPCALC(1) from the ipcalc source, dated October 2026. Go forth and subnet responsibly. π¦πΈπ
π¦ where this page comes from
- fedora 44: ipcalc 1.2.0-1.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms