There's a number of cases where you'll need to find the range for a particular IP address or --- # IPv4 overview If you've spent any amount of time trying to work out why the internet isn't working you've probably run into IP addresses before. Although the IPv6 standard ([RFC 2460](https://tools.ietf.org/html/rfc2460)) is growing in popularity, the IPv4 standard ([RFC 791](https://tools.ietf.org/html/rfc791) is still the most commonly used standard due to the slow takeup in ISPs and hardware. The addresses are used much like addresses in the physical world, they help route information from sources to destinations without getting lost. IPv4 addresses are traditionally represented by four numbers separated by periods. Each number represents a "byte" and can be a value from 0 to 255. As computers use binary, they recognise IP addresses as 32 bits, a stream of thirty two 1s and 0s. Knowing that computers see each IPv4 address as 32 numbers instead of 4 will come in handy when we get to subnet masks. Alongside the address assigned to your device you'll usually find two other addresses. One will be a subnet mask and the other will be the network address. # Subnet Mask Subnet masks are 32 bits long as well, but they consist of a contiguous section of 1s followed by all 0s. As an example, a common subnet mask on home routers is 255.255.255.0, which translated to binary becomes 11111111 11111111 11111111 00000000. The significance of this address is it defines which part of your IP address identifies the network that you are on (the 1s), and which part identifies the host you use (the 0s). You can use a visual aid to identify the network/host components by converting the IP address to binary and doing a bitwise AND operation (only 1 if both inputs are 1) against the subnet mask, anything that remains is the network component.
192.168.0.12 - IP address
255.255.255.0 - Subnet mask

Convert to binary

11000000 10101000 00000000 00001100
11111111 11111111 11111111 00000000

Bitwise AND

11000000 10101000 00000000 00000000

Convert to network address

192.168.0.0
# Classless Inter-Domain Routing (CIDR) One thing to be wary of is that not all subnet masks will be broken up nicely on the byte barrier. What happens when you run into situation like 172.16.189.75/19? *Wait where's the subnet mask and what the heck is that part at the end of our IP?* Looks like we've just run into CIDR notation; that "/19" is the number of bits for the network address, which is another way of representing a subnet mask. So we have 19 network bits, which will look a bit like 11111111 11111111 11100000 00000000. This can be converted back to four octets which will look like 255.255.224.0 now let's use the process from before to work out our network address.
172.16.189.75 - IP address
255.255.224.0 - Subnet mask
Convert to binary

10101100 00010000 10111101 01001011
11111111 11111111 11100000 00000000

Bitwise AND

10101100 00010000 10100000 00000000

Convert to network address

172.16.160.0