How to Find Your Network IP Address and Other Details
Table of Contents
Ever wondered how to find a network address using a subnet mask and an IP address? Or how to determine the broadcast address, the minimum and maximum host addresses, and the total number of hosts? Today, I’ll teach you how!
P.S. Check the glossary at the end for definitions of key terms.
How to Find the Network Address #
First, we need the IP address and its CIDR notation. An example problem could be:
172.31.32.0/20
-
Let’s break down the IP address. We have the IPv4 address (
172.31.32.0) and the/20CIDR notation. -
The
/20means the first 20 bits of the address are reserved for the network. Since each of the four segments in an IPv4 address holds 8 bits, we have a total of 32 bits (8 x 4 = 32). Subtracting the 20 reserved network bits from the total leaves 12 bits for individual hosts. To find the network address, you first need the subnet mask in binary. For a/20CIDR, the subnet mask consists of 20 ones followed by 12 zeros.Subnet Mask in Binary:
11111111.11111111.11110000.00000000 -
Next, convert the given IP address (172.31.32.0) to binary. You can use my Rust program for this.
IP Address in Binary:
10101100.00011111.00100000.00000000 -
Perform a bitwise
ANDoperation between the IP address and the subnet mask.10101100.00011111.00100000.00000000 (IP Address) & 11111111.11111111.11110000.00000000 (Subnet Mask) = 10101100.00011111.00100000.00000000 (Network Address)Converting this back to decimal gives us the network address:
172.31.32.0 -
Hooray! You’ve successfully found the network address.
How to Find the Broadcast Address #
Finding the broadcast address is much easier. It’s always the last address in the subnet.
-
Start with the network address in binary. Then, for the host portion (the last 12 bits in this case), change all the zeros to ones.
Warning: Do not change the network portion of the address; keep it fixed!
10101100.00011111.00100000.00000000 -> 10101100.00011111.00111111.11111111 -
Convert the resulting binary back to decimal, and you’re done!
10101100.00011111.00111111.11111111 -> 172.31.47.255
Minimum, Maximum, and Total Hosts #
-
Minimum Host: The first usable host address is the network address + 1.
172.31.32.1 -
Maximum Host: The last usable host address is the broadcast address - 1.
172.31.47.254 -
Total Hosts: The total number of addresses in the subnet (including the network and broadcast addresses) is 2^12, which equals 4096.
-
Available Hosts: The number of usable hosts for devices is 2^12 - 2 (subtracting the network and broadcast addresses), which is 4094.
Glossary #
- CIDR notation: The number of bits in the IP address that are fixed as the network portion.
- Subnet Mask: A 32-bit number that separates the network address from the host address.
- AND operation: A bitwise operation where the result is 1 only if both input bits are 1; otherwise, the result is 0. (e.g.,
1 & 1 = 1,1 & 0 = 0,0 & 0 = 0).
The End. Or is it?