whatmask
Whatmask is a subnet mask notation conversion tool that helps with network settings by converting between various netmask formats and calculating subnet details. It supports two modes: subnet mask conversion alone or full network information from an IP address and netmask.
Description
Whatmask is a small C program designed to assist with network settings, particularly subnet calculations and mask notation conversions. It supports four netmask notations: CIDR (e.g., /24), Netmask (e.g., 255.255.255.0), Netmask (Hex) (e.g., 0xffffff00), and Wildcard Bits (e.g., 0.0.0.255). In the first mode, providing only a subnet mask outputs equivalents in all four formats plus the number of usable addresses. The second mode takes an IP address followed by a slash and netmask, providing comprehensive subnet information including network address, broadcast, usable IPs, and first/last usable addresses.
Use cases include network configuration, troubleshooting subnet issues, and quick calculations for IP planning on Unix, Windows, Mac systems, and routers. It assumes the broadcast address is the highest in the subnet, which is the most common setup. No options or flags are available; usage relies on direct argument input without spaces in IP/netmask format.
How It Works
Whatmask parses input subnet masks in any of four supported notations (CIDR with or without slash, dotted decimal netmask, hex netmask, wildcard bits) and converts them to all formats while computing usable address counts based on host bits. In IP/netmask mode, it applies the mask to the given IP to derive the network address (IP AND netmask), broadcast (network OR inverted mask), usable IPs (2^hostbits - 2), first usable (network + 1), and last usable (broadcast - 1). Outputs are formatted consistently with labels for clarity.
Installation
sudo apt install whatmaskExamples
whatmask /26whatmask 255.255.192.0whatmask 0xffffffe0whatmask 192.168.165.23/19whatmask 192.168.0.13/255.255.255.0whatmask 192.168.0.113/0xffffffe0whatmask 192.168.0.169/0.0.0.127