Simula Research Laboratory / Center for Resilient Networks and Applications / NorNet
Homepage of Thomas Dreibholz / SubNetCalc Homepage


SubNetCalc
An IPv4/IPv6 Subnet Calculator

Screenshot of SubNetCalc run


πŸ“‘ Quick Navigation


πŸ“° Latest News


πŸ’‘ What is SubNetCalc?

SubNetCalc is an IPv4/IPv6 subnet address calculator. For a given IPv4 or IPv6 address and netmask or prefix length, it calculates network address, broadcast address, maximum number of hosts and host address range. Also, it prints the addresses in binary format for better readability. Furthermore, it prints useful information on specific address types (e.g., type, scope, interface ID).


πŸ˜€ Examples


πŸ“¦ Binary Package Installation

Please use the issue tracker at https://github.com/dreibh/subnetcalc/issues to report bugs and issues!

Ubuntu Linux

For ready-to-install Ubuntu Linux packages of SubNetCalc, see the Launchpad PPA for Thomas Dreibholz!

sudo apt-add-repository -sy ppa:dreibh/ppa
sudo apt-get update
sudo apt-get install subnetcalc

Debian Linux

For ready-to-install Debian Linux packages of SubNetCalc, see the Open Build Service PPA for Thomas Dreibholz!

Add the PPA repository:

. /etc/os-release
DISTRIBUTION="Debian_${VERSION_ID:-$([ "${VERSION_CODENAME:-}" = sid ] && echo Unstable || echo Testing)}"
URL="https://download.opensuse.org/repositories/home:/dreibh/${DISTRIBUTION}"
KEY="/etc/apt/keyrings/dreibh-obs.gpg"

curl -fsSL "${URL}/Release.key" | sudo gpg --batch --yes --dearmor -o "${KEY}"
printf "deb [signed-by=%s] %s/ /\ndeb-src [signed-by=%s] %s/ /\n" "${KEY}" "${URL}" "${KEY}" "${URL}" | \
   sudo tee /etc/apt/sources.list.d/obs-dreibh.list
sudo apt update

Then, install SubNetCalc:

sudo apt-get install subnetcalc

Fedora Linux

For ready-to-install Fedora Linux packages of SubNetCalc, see the COPR PPA for Thomas Dreibholz!

sudo dnf copr enable -y dreibh/ppa
sudo dnf install subnetcalc

OpenSUSE Linux

For ready-to-install OpenSUSE Linux packages of SubNetCalc, see the Open Build Service PPA for Thomas Dreibholz!

Add the PPA repository:

. /etc/os-release
[[ $VERSION_ID =~ ^[0-9]+\.[0-9]+$ ]] && DISTRIBUTION="${VERSION_ID}" || DISTRIBUTION="${NAME// /_}"
URL="https://download.opensuse.org/repositories/home:/dreibh/${DISTRIBUTION}"
rpm --import "${URL}/repodata/repomd.xml.key"
zypper addrepo -f "${URL}/" dreibh-obs

Then, install SubNetCalc:

sudo zypper install subnetcalc

Alpine Linux

For ready-to-install Alpine Linux packages of SubNetCalc, see the Open Build Service PPA for Thomas Dreibholz!

Add the PPA repository:

DISTRIBUTION="Alpine_Latest_community"
URL="https://download.opensuse.org/repositories/home:/dreibh"
wget -O \
   /etc/apk/keys/home:dreibh@build.opensuse.org-527a4e72.rsa.pub \
   "${URL}/${DISTRIBUTION}/x86_64/home:dreibh%40build.opensuse.org-527a4e72.rsa.pub"
if ! grep -q "^${URL}/${DISTRIBUTION}" /etc/apk/repositories ; then
   echo "${URL}/${DISTRIBUTION}" | sudo tee -a /etc/apk/repositories
fi

Then, install SubNetCalc:

sudo apk add subnetcalc

FreeBSD

For ready-to-install FreeBSD packages of SubNetCalc, it is included in the ports collection; see FreeBSD ports tree index of net/subnetcalc/!

sudo pkg install subnetcalc

Alternatively, to compile it from the ports sources:

cd /usr/ports/net/subnetcalc
make
sudo make install

NetBSD

SubNetCalc supports NetBSD. However, there is no NetBSD packaging yet. Just build from sources!

OpenBSD

SubNetCalc supports OpenBSD. However, there is no OpenBSD packaging yet. Just build from sources!

Solaris (OpenIndiana)

SubNetCalc supports Solaris (OpenIndiana). However, there is no Solaris packaging yet. Just build from sources!

GNU Hurd

SubNetCalc supports GNU Hurd (Debian GNU/Hurd). However, there is no Debian GNU/Hurd PPA on Open Build Service available yet. Just build from sources!

Homebrew (Apple, Linux)

For the Homebrew formula of SubNetCalc, see Thomas Dreibholz’s Homebrew Tap!

Add tap:

brew tap dreibh/tap
brew trust dreibh/tap

Then, install SubNetCalc:

brew install subnetcalc

πŸ’Ύ Build from Sources

SubNetCalc is released under the GNU General Public License (GPL).

Please use the issue tracker at https://github.com/dreibh/subnetcalc/issues to report bugs and issues!

Development Version

The Git repository of the SubNetCalc sources can be found at https://github.com/dreibh/subnetcalc:

git clone https://github.com/dreibh/subnetcalc
cd subnetcalc
sudo ci/get-dependencies --install
cmake .
make

Optionally, for installation to the standard paths (usually under /usr/local):

sudo make install

Note: The script ci/get-dependencies automatically installs the build dependencies under Debian/Ubuntu Linux, Fedora Linux, OpenSUSE Linux, Alpine Linux, FreeBSD, and Debian GNU/Hurd. For manual handling of the build dependencies, take a look at the packaging configuration files:

Contributions:

Current Stable Release

The tarball has been signed with my GnuPG key 21412672­518D8B2D­1862EFEF­5CD5D12A­A0877B49. Its authenticity and integrity can be verified by:

gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 21412672518D8B2D1862EFEF5CD5D12AA0877B49
gpg --verify subnetcalc-<VERSION>.tar.xz.asc subnetcalc-<VERSION>.tar.xz

Old Stable Releases

The tarballs have been signed with my GnuPG key 21412672­518D8B2D­1862EFEF­5CD5D12A­A0877B49. Its authenticity and integrity can be verified by:

gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 21412672518D8B2D1862EFEF5CD5D12AA0877B49
gpg --verify subnetcalc-<VERSION>.tar.xz.asc subnetcalc-<VERSION>.tar.xz

🌏 Internationalisation

To provide a translation of SubNetCalc into your language, apply the following steps:

  1. Build SubNetCalc from the Git sources (see Development Version), i.e., use the β€œmaster” branch with the latest development version. The build will create a .pot (translation template) file under po.

  2. Create a new Git branch for your translations, e.g., my_username/translations_language_XX (where XX is the language code for your language, e.g., da for Danish):

    git branch my_username/translations_language_XX
    git checkout my_username/translations_language_XX
  3. Take a look at the existing .po files (translation files) in po/de (German) and po/nb (BokmΓ₯l) as examples, e.g., po/de/subnetcalc.po or po/nb/subnetcalc.po. Then, prepare a translation for your language XX under po:

    mkdir -p XX
    msginit --input subnetcalc.pot \
            --locale XX.UTF-8 \
            --output-file XX/subnetcalc.po
    git add XX/subnetcalc.po
  4. Add your translations into XX/subnetcalc.po, with a text editor or PO file editor like Poedit.

  5. Test, commit and push your changes.

  6. Finally, make a pull request: https://github.com/dreibh/subnetcalc/pulls.