Information Gatheringnetmasknetworkfirewallroutercidrip

netmask

netmask helps determine network masks and convert between common IP netmask and address formats. It is a tiny program handy for firewalls, routers, or shell scripts to specify ranges of hosts with the smallest set of network masks.

Description

netmask is a utility designed to assist users working with firewalls or routers, particularly in scenarios requiring precise network mask calculations. It determines the smallest set of network masks needed to specify a range of hosts, making it useful as a helper in shell scripts.

The tool supports conversion between various IP netmask and address formats, enhancing its utility in network configuration tasks. It accepts specifications like single addresses, address ranges (address:address or address:+address), or address/mask notations, where addresses can be decimal or octal numbers.

With output options for standard, CIDR, Cisco style, ranges, and hex formats, netmask streamlines network-related scripting and configuration.

How It Works

netmask processes input specifications such as addresses, address ranges (address:address or address:+address), or address/mask formats, where addresses are interpreted as decimal (N) or octal (0N) numbers. It generates the smallest set of network masks covering the specified host range and outputs in selected formats like standard address/netmask pairs, CIDR, Cisco style lists, IP ranges, or hexadecimal, using debug mode for status information.

Installation

bash
sudo apt install netmask

Flags

-h, --helpPrint a summary of the options
-v, --versionPrint the version number
-d, --debugPrint status/progress information
-s, --standardOutput address/netmask pairs
-c, --cidrOutput CIDR format address lists
-i, --ciscoOutput Cisco style address lists
-r, --rangeOutput ip address ranges
-x, --hexOutput address/netmask pairs in hex

Examples

Print a summary of the options for netmask
netmask -h
Process a single address specification to generate netmask information
netmask 192.168.1.1
Specify an address range using address:address format
netmask 192.168.1.1:192.168.1.10
Specify a range starting from an address plus an offset using address:+address format
netmask 192.168.1.1:+5
Process an address/mask specification
netmask 192.168.1.0/24
Output address/netmask pairs in standard format for a CIDR spec
netmask -s 192.168.1.0/24
Output CIDR format address lists for an address range
netmask -c 192.168.1.1:192.168.1.10
Updated 2026-04-16kali.org ↗