Dotted-decimal addresses
On this page
You found inet 10.77.10.10/24 in Reading a machine’s network settings. The address has four numbers and three dots. Why four, and why does each number stop at 255? Here you will read that shape and reject strings that cannot fit it.
Before you start
Section titled “Before you start”Finish Practice: Ethernet and Local Delivery. Have the lab running in its starting state, with modes off. Begin at learner@rootvolt:~$, outside any machine shell. These reads change no settings, so you do not need a reset between them.
Read the number after inet
Section titled “Read the number after inet”An IPv4 address is a 32-bit address used by the internet layer to name an interface. A bit is a single 0 or 1. The familiar written form groups those bits into four sets of eight. An octet is one group of eight bits.
The decimal form writes each octet as an ordinary base-ten number. Dots separate the four numbers. They are separators for people reading the address; they do not add bits to it. Four groups of eight give 32 bits altogether. Read the whole address, including repeated numbers. Two equal octets still occupy two different positions.
The figure shows the same address in two forms. You do not need to convert the bit strings yet. Count eight positions under each decimal number. Each position has two possible values. That gives 256 possible patterns in an octet. Counting from zero, those patterns represent values from 0 through 255: 00000000 is 0 and 11111111 is 255. There is no 257th pattern for 256.
Check the shape before asking what it means
Section titled “Check the shape before asking what it means”Predict which of these five strings cannot have IPv4 address format: 192.0.2.7, 192.0.2.256, 198.51.100.7.1, 203.0.113.0, 10.77.10.10. Write a reason beside each rejection, then use the figure above to check your count.
Check your answer
192.0.2.256 fails because 256 exceeds one octet’s limit. 198.51.100.7.1 has five numbers. The other three have the right format. That judgment does not say whether you may assign them to an ordinary interface.
A format check asks only about the written numbers. It does not establish that somebody uses the address, that it can receive a message, or that it has a particular purpose. Keep those questions separate. A zero in one position does not by itself make the written format invalid.
Find the interface that owns it
Section titled “Find the interface that owns it”Repeat the replay’s commands. As in the previous module, netlab shell <machine> -- <command> runs one command there and returns to the VM. Answer the password question if it appears.
learner@rootvolt:~$ netlab shell laptop -- ip -br address[sudo] password for learner: lo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if3 UP 10.77.10.10/24 fe80::77:10ff:fe00:10/64 learner@rootvolt:~$ netlab shell router -- ip -br addresslo UNKNOWN 127.0.0.1/8 ::1/128
eth0@if7 UP 10.77.10.1/24 fe80::77:10ff:fe00:1/64
eth1@if9 UP 10.77.20.1/24 fe80::77:20ff:fe00:1/64 learner@rootvolt:~$ Steps (9)
- Type
netlab shell laptop -- ip -br address - Press Enter
- Output:
[sudo] password for learner: - Type the password (the terminal shows nothing)
- Press Enter
- Output:
lo UNKNOWN 127.0.0.1/8 ::1/128 eth0@if3 UP 10.77.10.10/24 fe80::77:10ff:fe00:10/64 - Type
netlab shell router -- ip -br address - Press Enter
- Output:
lo UNKNOWN 127.0.0.1/8 ::1/128 eth0@if7 UP 10.77.10.1/24 fe80::77:10ff:fe00:1/64 eth1@if9 UP 10.77.20.1/24 fe80::77:20ff:fe00:1/64
Laptop’s eth0@if3 has 10.77.10.10/24. Reading a machine’s network settings explained the @if3 suffix. The fe80:: value is an IPv6 address, which this module does not use; IPv6 Foundations explains it. Leave the slash and number for the next lesson.
Router has two non-loopback interface rows: eth0@if7 has 10.77.10.1/24, and eth1@if9 has 10.77.20.1/24. These are two IPv4 addresses on one machine. Match an address to its row before describing where it belongs.
Mistakes to recognize
Section titled “Mistakes to recognize”“The dots separate network, sub-network, floor and device.” They only separate octets. No octet means a building floor. The next lesson shows what decides the network part.
“A machine has one address.” Router’s two interface rows disprove that rule. An address belongs to an interface; one machine can have several.
Good to know
Section titled “Good to know”Write each octet without leading zeros: 10.77.10.10, not 010.077.010.010. Some programs read a number with a leading zero in another number system, so it can become a different address.
Try it yourself
Section titled “Try it yourself”Mark these ten strings valid in format or invalid. Write the failed rule for each invalid string: 192.0.2.9, 198.51.100.25, 203.0.113.255, 10.77.20.80, 192.168.0.0, 192.0.2.300, 198.51.100, 203.0.113.1.2, 192.0.-2.9, 192..2.9. Then run netlab shell phone -- ip -br address and netlab shell web -- ip -br address. Write each IPv4 address’s four octets and compare them with your format rules.
Solution
The first five pass the format check. The last five fail: too large, too few numbers, too many numbers, a negative number, and a missing number. Phone has 10.77.10.11/24; web has 10.77.20.80/24. Their four octets are 10, 77, 10, 11 and 10, 77, 20, 80. Both pass. The next lesson reads the /24. Passing this check alone does not make a string suitable for use on your network.
Leave for later
Section titled “Leave for later”Binary where it helps in Subnetting Foundations explains converting between binary and decimal.
- An IPv4 address contains four eight-bit octets.
- Each decimal octet ranges from 0 to 255.
- Read the interface row before assigning meaning to an address.
Next, Networks, hosts, and prefixes reads the slash after the address.
Further reading
Section titled “Further reading”- Ubuntu: ip-address manual, for the address listing.