Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  SUBCALC (1)


subcalc - Advanced IP/IPv6 subnet calculation and discovery


See Also


subcalc [address family] [address] [print] subcalc [address family] [address] [netmask] [mask] [print] subcalc [address family] [address] [prefixlen] [len] [print] subcalc [address family] [hosts] [number] subcalc [int6] [address] [hostname] subcalc [arpa6] [address] [hostname] subcalc [stf] [address family] [address]


The subcalc utility is used for subnet calculation and IPv6 DNS PTR record generation. subcalc takes command line arguments in a similar format to ifconfig(8) so the synopsis should be familiar to the user. Given an address family, address and a netmask/prefix length, subcalc will calculate the number of hosts and address ranges of the specific network. Specifying the ‘‘print’’ option to to the end of the command line will result in every single network address for the specified network being printed to stdout.

subcalc was designed for network engineers which setup fine grained firewalls, packet filters, access control lists and network subdivisions for both IP and IPv6 servers and networks.

The following options are available:
  Specify the address family which affects interpretation of the remaining parameters. Since subcalc can handle subnet calculations in different protocols with different naming schemes, specifying the address family is recommended. The address or protocol families currently supported are "inet" and "inet6".
  For the DARPA -Internet family, the address is an Internet address expressed in the Internet standard "dot notation".

It is also possible to use the CIDR notation (also known as the slash notation) to include the netmask. That is, one can specify an address like

For "inet6" family, it is also possible to specify the prefix length using the slash notation, like ::1/128. See the prefixlen parameter below for more information.

arpa6 address
  Generate an ARPA6 PTR record which the popular DNS server ‘‘BIND’’ will understand. In order for the components of the PTR record to be complete, a hostname must be specified as well.
hosts number
  Specify the number of nodes or addresses on a network and subcalc will calculate an appropriate network subdivision and bits. This is used for netmask discovery. NOTE: currently subcalc calculates the subdivision for one network. In some cases it may be more efficient to use more then one network subdivision.
int6 address
  Generate an INT6 PTR record which the popular DNS server ‘‘BIND’’ will understand. In order for the components of the PTR record to be complete, a hostname must be specified as well.
netmask mask
  Specify how much of the address to reserve for subdividing networks into sub-networks. The mask includes the network part of the local address and the subnet part, which is taken from the host field of the address. The mask can be specified as a single hexadecimal number with a leading 0x’, or with a dot-notation Internet address. The mask contains 1’s for the bit positions in the 32-bit address which are to be used for the network and subnet parts, and 0’s for the host part. The mask should contain at least the standard network portion, and the subnet field should be contiguous with the network portion.

The netmask can also be specified in CIDR notation after the address. See the address option above for more information.

prefixlen len
  Specify that len bits are reserved for subdividing networks into sub-networks. The len must be an integer, and for syntactical reason it must be between 0 to 128. It is almost always 64 under the current IPv6 assignment rule. If the parameter is omitted, 64 is used.

The prefix can also be specified using the slash notation after the address. See the address option above for more information

print causes each address in the specified network to be printed to stdout, one address per line. Regular subnet calculation is still performed, however each line of the standard calculation output is prefixed by a ‘‘;’’ character. This makes it easy for standard subnet calculations to be filtered out, in the event that network lists need to be generated.
stf If the address family is inet, translate the argument as an IPv4 address which will be converted into the arbitrary IPv6 ‘‘/48’’ (6to4 rfc3056) network designation. If the family is inet6, translate the argument as an IPv6 network or address specification which will be converted into it’s arbitrary IPv4 parent address.


To calculate the network range, number of hosts, prefixlen or CIDR and netmask for the ( network.

Anyone of the following will achieve the exact same thing:

To generate a list of nodes for the specified network one could use anyone of the following methods:

Arbitrarily, the same thing can be done for IPv6. To calculate the network range, number of hosts, prefixlen etc for the 3ffe:beef:13e1:4c92::cd90/48 network, one could use any of the following:

Likewise for printing each node of a network:

IP version 4 PTR records (records which map an address to a canonical name) contain a portion which has a reversed version of the IP octet prefixing the zone. For example, an RFC 1035 PTR record for would look like:

The first section of this PTR record is called the ‘‘owner’’:

For IP version 6, rather then reversing each octet, PTR records require that each ‘‘nibble’’ or 4 bit address subdivision be reversed. For example, the owner section of a PTR record for the IPv6 address 3ffe:beef:13e1:4c92::cd90 would be:

Creating PTR record for IP version 6 addresses can be tedious and more prone to error. subcalc has the capability to automatically subdivide the IPv6 address into nibbles and reverse them into a PTR record like format. An example on how this might be achieved is:

If you wanted to calculate a subdivision for a network given the number of nodes or hosts, you could do:

The next highest network subdivision in this case would be a ‘‘/27’’ which has 32 hosts. The netmask for this network would be:

Given an IPv4 address, figure out the 6to4 IPv6 ‘‘/48’’ network associated with it.

Given an IPv6 network or address, figure out what IPv4 address represents the parent for the network.


The subcalc utility and this man page was written by Christian S.J. Peron. Send any bugs or patches to (


ifconfig(8), inet(4), netintro(4), netstat(1), stf(4)

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.