|
NAMEsubcalc —
Advanced IP/IPv6 subnet calculation and discovery
SYNOPSIS
DESCRIPTIONThesubcalc 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.
The following options are available:
EXAMPLESTo 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 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
AUTHORThesubcalc utility and this man page was written by
Christian S.J. Peron. Send any bugs or patches to (csjp@sqrt.ca).
SEE ALSOifconfig(8), inet(4), netintro(4), netstat(1), stf(4)
Visit the GSP FreeBSD Man Page Interface. |