Mastering Binary: The Foundation of IP Networking

We're going back to the absolute bedrock of networking: the ones and zeros. If you don't understand how a router thinks, you'll never truly master it. And routers think in binary.

Part 1: From Decimal to Binary - Speaking the Language
Computers don't understand 192. They understand ON and OFF, which we represent with 1 and 0. In IPv4, we group these into 8-bit sets called octets. To convert a decimal number, we use the powers of 2. These 8 values are your new best friends.
Bit Position87654321
Value1286432168421

The Conversion Process: A Simple Question

To convert a decimal number, start from the largest value (128) and ask a simple question: "Can I subtract this value from my number and not get a negative result?"

  • If YES, put a 1 in that bit's position and continue with the remainder.
  • If NO, put a 0 in that position and move to the next smaller value.

Example 1: Convert 192 to Binary

Our number is 192. Start at 128. Is 192 >= 128? Yes. Remainder: 192 - 128 = 64.

[ 1 ] [ _ ] [ _ ] [ _ ] [ _ ] [ _ ] [ _ ] [ _ ]

Next, use the remainder 64. Is 64 >= 64? Yes. Remainder: 64 - 64 = 0.

[ 1 ] [ 1 ] [ _ ] [ _ ] [ _ ] [ _ ] [ _ ] [ _ ]

The remainder is 0, so the rest are 0s.

Result: 192 = 11000000

Example 2: Convert 172 to Binary

172 >= 128? Yes. (1) Remainder: 44.

44 >= 64? No. (0)

44 >= 32? Yes. (1) Remainder: 12.

12 >= 16? No. (0)

12 >= 8? Yes. (1) Remainder: 4.

4 >= 4? Yes. (1) Remainder: 0.

Remainder is 0, so the rest are 0s.

Result: 172 = 10101100

Part 2: From Binary to Decimal - Translating Back
Going the other way is even easier. Take your 8-bit binary number and place it back in our chart. Wherever there is a 1, add that position's value to your total.

Example: Convert 11100000 to Decimal

( 1 * 128 ) + ( 1 * 64 ) + ( 1 * 32 ) = 224

Result: 11100000 = 224

Part 3: The Subnet Mask - The Magic Decoder
An IP address has two parts: a Network part (the "street") and a Host part (the "house"). The Subnet Mask is a stencil that tells a router which part is which.
  • If a mask bit is 1, the corresponding IP bit is part of the NETWORK.
  • If a bit in the subnet mask is a 0, the corresponding IP bit is part of the HOST.

Example: IP 192.168.1.10 with Mask 255.255.255.0

TypeOctet 1Octet 2Octet 3Octet 4
IP Address11000000101010000000000100001010
Subnet Mask11111111111111111111111100000000
ResultNETWORKNETWORKNETWORKHOST

Because the first three octets of the mask are all 1s (decimal 255), the first three octets of the IP (192.168.1) are the Network ID. Because the last octet of the mask is all 0s, the last octet of the IP (10) is the Host ID.

Part 4: Your Turn - The Visualizer

Theory is one thing, practice is another. Use the tool below to enter any IPv4 address and use the slider to change the mask. It will instantly convert it to binary and show you exactly which bits are for the network and which are for the host.

Interactive IP to Binary Converter

Instantly see Network & Host bits as you type.

192NETWORK
128 64 32 16 8 4 2 1
11000000
168NETWORK
128 64 32 16 8 4 2 1
10101000
1NETWORK
128 64 32 16 8 4 2 1
00000001
10HOST
128 64 32 16 8 4 2 1
00001010
Network Bit
Host Bit