Skip to content

Binary where it helps

Module
Subnetting Foundations
Difficulty
Easy
Updated
Tested on
Ubuntu 24.04.5 LTS, netlab 1.0, GNU Bash 5.2.21, tcpdump 4.99.4
On this page

The boundary for /24 falls on a dot. The boundary for /26 does not: it splits the fourth octet inside. Decimal numbers hide that split. You need a way to see individual positions before deciding which belong to the network.

Seven questions from laptop to web A horizontal line joins laptop to web through seven numbered circles. Station 3 is the focus: is web local or beyond router? No station is fully answered yet. laptop web 1 2 3 4 5 6 7
Seven questions from laptop to web A horizontal line joins laptop to web through seven numbered circles. Station 3 is the focus: is web local or beyond router? No station is fully answered yet. laptop web 1 2 3 4 5 6 7
Station 3: is web on laptop's own network or beyond the router? This module answers it from laptop's own settings. The other questions remain open.

Finish Practice: Understanding IPv4 Addresses. Keep the lab up in its starting state, with modes off. Begin at learner@rootvolt:~$. These address reads change no settings. Answer the password question if it appears.

Recall that a bit is a single 0 or 1. Binary is the base-2 way of writing numbers. Each place is worth twice the place to its right. For one octet, the values from left to right are 128, 64, 32, 16, 8, 4, 2 and 1. A 1 includes that place’s value; a 0 leaves it out.

The figure uses 77, laptop’s second octet. Read each bit under its place value. The included values add up to the decimal number below the row.

Eight places represent 77 Included place values 64, 8, 4 and 1 represent the captured second octet, 77. Ones are labeled and colored. 128 0 64 1 32 0 16 0 8 1 4 1 2 0 1 1 64 + 8 + 4 + 1 = 77
Eight places represent 77 Included place values 64, 8, 4 and 1 represent the captured second octet, 77. Ones are labeled and colored. 128 0 64 1 32 0 16 0 8 1 4 1 2 0 1 1 64 + 8 + 4 + 1 = 77
Laptop's second octet, 77: the bits under 64, 8, 4 and 1 are 1, and those place values add up to 77.

Predict: what is the largest number eight bits can hold? Work it out from the place values before reading the answer.

Check your answer

Choose every place: 11111111 represents 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255. No place remains for a larger value within eight bits.

Start with 77. Ask whether 128 fits into the amount remaining. It does not, so write 0. The next value, 64, fits: write 1 and subtract it, leaving 13. Neither 32 nor 16 fits into 13, so write two zeros.

Eight fits, leaving 5. Four fits, leaving 1. Two does not fit. One does. Reading those choices from the left gives 01001101. When you finish, check that you have written exactly eight bits and the remainder is 0.

Try the same process slowly before trying to recognize familiar patterns. At each place, compare with the remainder, rather than with the original number.

For 10100000, include 128 and 32. Leave out every other place. Their sum is 160. Start the place values at the left even when the string begins with zero. The zeros hold positions; they do not move the other bits.

Check a conversion by reversing it. If adding gives a different number, line up the eight places again. Writing the place values above the bits makes an error easier to find than looking only at the final answer.

Compare 01001101 with 01001100. Their first seven bits match; the last differs. Now compare 11000000 with 11100000: the first difference is the third place. A prefix comparison stops after its stated number of bits. Differences after that boundary belong to the host part.

For /26, the first three octets are whole network octets. Only two bits of the fourth octet join them. Compare those two leading bits when the first three octets already match. You do not need to rewrite every earlier octet in binary.

“I must convert whole addresses.” Only the octet where the prefix ends needs binary. Whole network octets can be compared as decimal numbers; /26 leaves the first three whole.

The next lesson builds masks from octets whose ones all sit on the left, such as 11000000. Recognizing that shape will help you read the boundary between network and host bits.

Convert these eight decimal values to eight-bit binary: 192, 224, 240, 248, 252, 128, 64, 80. Convert these eight binary values to decimal: 00000001, 00000010, 00000100, 00001000, 00010000, 00100000, 01100000, 10100000. Write your answers first. Then repeat the replay below, read phone’s and web’s last IPv4 octets, convert them, and compare by adding the included place values.

Read phone and web octets
learner@rootvolt:~$ netlab shell phone -- ip -br address[sudo] password for learner: lo               UNKNOWN        127.0.0.1/8 ::1/128 
eth0@if5         UP             10.77.10.11/24 fe80::77:10ff:fe00:11/64 learner@rootvolt:~$ netlab shell web -- ip -br addresslo               UNKNOWN        127.0.0.1/8 ::1/128 
eth0@if11        UP             10.77.20.80/24 fe80::77:20ff:fe00:80/64 learner@rootvolt:~$ 

Step-by-step replay of a verified session · Recorded on Ubuntu 24.04.5 LTS, networking lab (netlab 1.0), GNU Bash 5.2.21. Read the two last octets from their interface rows before converting them.
Steps (9)
  1. Type netlab shell phone -- ip -br address
  2. Press Enter
  3. Output: [sudo] password for learner:
  4. Type the password (the terminal shows nothing)
  5. Press Enter
  6. Output: lo UNKNOWN 127.0.0.1/8 ::1/128 eth0@if5 UP 10.77.10.11/24 fe80::77:10ff:fe00:11/64
  7. Type netlab shell web -- ip -br address
  8. Press Enter
  9. Output: lo UNKNOWN 127.0.0.1/8 ::1/128 eth0@if11 UP 10.77.20.80/24 fe80::77:20ff:fe00:80/64
Solution

In order, the first set gives 11000000, 11100000, 11110000, 11111000, 11111100, 10000000, 01000000, 01010000. The second gives 1, 2, 4, 8, 16, 32, 96, 160. Phone has 10.77.10.11/24: 11 becomes 00001011. Web has 10.77.20.80/24: 80 becomes 01010000. Adding gives 8 + 2 + 1 and 64 + 16 respectively.

  • Write one bit per place value.
  • Subtract to convert to binary; add to return to decimal.
  • Compare only the positions selected by the prefix.

Next, Masks and CIDR notation writes the boundary another way.