subcalc man page on DragonFly

Man page or keyword search:  
man Server   44335 pages
apropos Keyword Search (all sections)
Output format
DragonFly logo
[printable version]

SUBCALC(1)		  BSD General Commands Manual		    SUBCALC(1)

NAME
     subcalc — Advanced IP/IPv6 subnet calculation and discovery

SYNOPSIS
     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]

DESCRIPTION
     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 net‐
     work being printed to stdout.

     subcalc was designed for network engineers which setup fine grained fire‐
     walls, 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 calcula‐
	     tions in different protocols with different naming schemes, spec‐
	     ifying the address family is recommended.	The address or proto‐
	     col 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.

     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 net‐
	     works 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 sub‐
	     net 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 specifica‐
	     tion which will be converted into it's arbitrary IPv4 parent
	     address.

EXAMPLES
     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

     To generate a list of nodes for the specified network one could use any‐
     one 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 net‐
     work 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 pre‐
     fixing 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 exam‐
     ple, 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 associ‐
     ated 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

AUTHOR
     The subcalc utility and this man page was written by Christian S.J.
     Peron.  Send any bugs or patches to (maneo@bsdpro.com).

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

BSD				August 22, 2003				   BSD
[top]

List of man pages available for DragonFly

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net