GSP
Quick Navigator

Search Site

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

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SUBCALC(1) FreeBSD General Commands Manual SUBCALC(1)

subcalc
Advanced IP/IPv6 subnet calculation and discovery

subcalc [address family] [address] [print]

subcalc [address family] [address] [netmask] [mask] [print]

subcalc [address family] [address] [mask] [ciscomask] [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:

address_family
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”.
address
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 192.168.0.1/16.

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.

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.
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.
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.
ciscomask
Specify the netmask in the format expected on Cisco routers. That is the inverted form of a netmask. For example, the netmask 255.255.255.0 would be represented as 0.0.0.255. This option is only applicable for IPv4, as on Cisco routers, CIDR notation is used to specify IPv6 network addresses.
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.

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

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.
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 10.0.0.1/24 (255.255.255.0) network.

% subcalc inet 10.0.0.1/24

Anyone of the following will achieve the exact same thing:

% subcalc inet 10.0.0.1 netmask 255.255.255.0
% subcalc inet 10.0.0.1 netmask 0xffffff00
% subcalc inet 10.0.0.1 prefixlen 24
% subcalc inet 10.0.0.1 mask 0.0.0.255

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

% subcalc inet 10.0.0.1/24 print
% subcalc inet 10.0.0.1 netmask 255.255.255.0 print
% subcalc inet 10.0.0.1 netmask 0xffffff00 print
% subcalc inet 10.0.0.1 prefixlen 24 print

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:

% subcalc inet6 3ffe:beef:13e1:4c92::cd90/48
% subcalc inet6 3ffe:beef:13e1:4c92::cd90 netmask ffff:ffff:ffff::
% subcalc inet6 3ffe:beef:13e1:4c92::cd90 prefixlen 48

Likewise for printing each node of a network:

% subcalc inet6 3ffe:beef:13e1:4c92::cd90/48 print
% subcalc inet6 3ffe:beef:13e1:4c92::cd90 prefixlen 48 print

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 in-addr.arpa. zone. For example, an RFC 1035 PTR record for 10.0.0.1 would look like:

1.0.0.10.in-addr.arpa. IN PTR canonical.name.org.

The first section of this PTR record is called the ``owner'':

1.0.0.10.in-addr.arpa.

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:

0.9.d.c.0.0.0.0.0.0.0.0.0.0.0.0.2.9.c.4.1.e.3.1.f.e.e.b.e.f.f.3.ip6.arpa.

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:

% subcalc arpa6 3ffe:beef:13e1:4c92::cd90 canonical.name.org.
% subcalc int6 3ffe:beef:13e1:4c92::cd90 canonical.name.org.

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

% subcalc inet hosts 23

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

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

% subcalc stf inet 204.55.55.1

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

% subcalc stf inet6 2002:cc37:3701::/48
% subcalc stf inet6 2002:cc37:3701:bc38::4081

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

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

March 17, 2016 FreeBSD 13.1-RELEASE

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 ManDoc.