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.
Bit Position | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
---|---|---|---|---|---|---|---|---|
Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
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.
Next, use the remainder 64. Is 64 >= 64? Yes. Remainder: 64 - 64 = 0.
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
Example: Convert 11100000 to Decimal
Result: 11100000 = 224
- 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
Type | Octet 1 | Octet 2 | Octet 3 | Octet 4 |
---|---|---|---|---|
IP Address | 11000000 | 10101000 | 00000001 | 00001010 |
Subnet Mask | 11111111 | 11111111 | 11111111 | 00000000 |
Result | NETWORK | NETWORK | NETWORK | HOST |
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.