Your "question" is actually a series of questions. For future reference, try to avoid this. :-) However, this question is a good one, and I think is an easy enough mistake to make by newcomers to the field, so I'll do my best to answer. Truth be told, your source of confusion has nothing to do with subnetting and everything to do with the show ip route
output itself (and understandably so).
172 is a class B network (/16). So that means 172.16.0.0/24 is already subnetted, since clearly /24 is greater than /16.
First things first - classful addressing and routing has been dead a long time. I understand that it's still part of networking curriculums though, so do yourself a favor and forget everything classful as soon as you're done with your coursework. IMO, still forcing people to learn about these topics only serves to confuse.
Secondly, the prefix length (subnet mask) has nothing to do with the class of the address. See this answer for more information on how classful addressing actually works (and for a hint at the answer to your very last question).
Now in the image it says 172.16.0.0/24 has two subnets: 172.16.1.0 and 172.16.2.0. But to me that seems weird, because when you subnet, the subnets have to be a subnetwork of the original network, right? But clearly 172.16.1.0 and 172.16.2.0 isn't in 172.16.0.0/24 since the range would be 172.16.0.0 - 172.16.0.255.
Like I said before, this has nothing to do with subnetting and everything to do with the structure of the output of show ip route
.
Way back when, when IOS first came around, there was classful addressing and routing, as you're being taught currently. The structure of the routing table back then was designed with classful routing in mind, and was hierarchical and had (and still has) many levels. When classless addressing and routing came around, the hierarchical structure of the routing table still worked, so it really hasn't changed much.
Ultimately the real answer lies in a textbook (one of my favorites) called Cisco IP Routing by Alex Zinin. Quote below, emphasis mine:
The subnet mask displayed with the parent network route is not the real subnet mask stored in the route entry but rather is the mask used for all subnets in the network. The subnet mask is not shown for each subnet only when all child routes have the same mask; that is, VLSM is not used. If more than one subnet mask is used in a major network, each subnet route is augmented with a specific route mask, and the major network is shown with the classful mask.
So in other words, show ip route
output can be somewhat misleading given the right circumstances. Relating back to your output, the major network boundary or classful boundary for the 172.16.1.0/24 subnet is 172.16.0.0. Since all of your subnets of 172.16.0.0 have a /24 length, the show ip route
output is really just telling you that it knows about the 172.16.0.0 classful network, and all of the subnetworks that it knows about for this major network have the same length, and that is /24.
Try adding a network to the routing table that's part of 172.16.0.0 and which has a "non-classful" length, such as a /27 or /25. What happens?
Also, one thing I don't understand is how the router knows the original network (in this case 172.16.0.0/24) when only the subnets are given. How does it figure this out?
Again, I'll urge you to read the previous answer which I'd linked, if this isn't already clear at this point. :-)
EDIT: To answer some further questions OP has in comments:
I'm confused about excercise 1 on 9tut.com/subnetting-tutorial/2. When I subnet I'm used to be given a network address like 4.0.0.0/24 and I would borrow host bits to create subnets. But in excercise 1 they figure out the major network boundary 4.0.0.0/8 and assume that all other class A networks are subnets to that major network boundary. Can you confirm this is correct? It confuses me because you told me that the classful boundary is rarely used these days, so I get the idea that this might be an old/obsolete way to think about subnetting.
It basically is an old way to look at subnetting. Determining the class of address is not needed to determine the number of subnets and hosts per subnet available. The question is worded poorly, and in the real world no one is going to be "assigned" an arbitrary prefix without a length attached to it, ie 4.0.0.0. You could easily find a different answer given the parameters of a /24 prefix length to be used for subnetting if they had given you any prefix length that was shorter than a /24, it doesn't necessarily have to be /8. It's likely that the exercise was worded in such a way to force the reader to remember the classes of addresses in order to answer it correctly.
To make my question a bit clearer, I'm going to give an example. Take a look back at the picture in my original question. The IP routing table says that 172.16.0.0/24 is subnetted and has 2 subnets. It seems the IP routing table also treats 172.16.1.0/24 and 172.16.2.0/24 as subnets because they are in the range of the major classful network 172.16.0.0/16 (i.e. 172.16.0.0 - 172.16.255.255). So this is probably how the routing table looks at subnets, correct?
Yes. Again, the internal structure of the routing table really hasn't changed since the days of classful routing. Anything that's viewed as a subnet of a classful network is going to be viewed as a subnet by the router.
One last thing: if I subnet a network address, I can always get this network back by supernetting the subnets, correct? This is then the answer to my last question my original post.
No, it isn't. Determining your major network or classful network boundary has nothing to do with subnetting or supernetting. It really isn't complicated.
- Step One: Determine the class of the address
- Step Two: Determine the classful network boundary by using the natural mask of the classful address.
Here's three examples of IP addresses with varying mask lengths:
- 115.65.6.18/20
- 200.200.200.200/27
- 188.154.17.8/15
For #1:
The address is Class A because the first octet is 115, and this falls within the range of numbers that have a leading bit of 0
(0 to 127). The natural mask for Class A networks is 255.0.0.0. So the classful network boundary is 115.0.0.0/8.
For #2:
The address is Class C because the first octet is 200, and this falls within the range of numbers that have leading bits of 110
(192 to 223). The natural mask for Class C networks is 255.255.255.0. So the classful network boundary is 200.200.200.0/24.
For #3:
The address is Class B because the first octet is 188, and this falls within the range of numbers that have leading bits of 10
(128 to 191). The natural mask for Class B networks is 255.255.0.0. So the classful network boundary is 188.154.0.0/16.
This is how the router is able to determine the classful network boundary of any subnet.
First, network classes are dead, killed in 1993 by RFCs 1517, 1518, and 1519, which defined CIDR (Classless Inter-Domain Routing). Later RFCs have further deprecated network classes. Modern networking doesn't use network classes, and you should only worry about them from a historical perspective.
IPv4 network classes were defined by the first few bits of the address, and IPv6 never had network classes. The latest RFC of which I know that defines network classes is RFC 1166, Internet Numbers*, which obsoleted the previous RFCs for network classes.
Class | Address starts with | Mask length
A | First bit is `0` | 8 bits
B | First two bits are `10` | 16 bits
C | First three bits are `110` | 24 bits
D | First four bits are `1110` | N/A
E | First four bits are `1111` | N/A
The network classes had specific mask lengths, but could be subnetted to longer mask lengths within a specific classful network. Unfortunately, many people confuse the network mask with the network class, and many of them will argue to the death that any /24
network is a Class C network, but that is not the definition of a network class.
So is IP address of 172.168.10/28 a Class B or Class C?
Actually, neither. The address 172.168.10/28
is actually an invalid IPv4 address. I will assume you meant 172.168.10.0/28
, which used to be a subnet of the 172.168.0.0/16
Class B network.
Today, trying to classify an address by network class is a pointless exercise because there is no longer any such thing.
*Copied from the RFC.
The first type of address, or class A, has a 7-bit network number and
a 24-bit local address. The highest-order bit is set to 0. This allows
128 class A networks.
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0| NETWORK | Local Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Class A Address
The second type of address, class B, has a 14-bit network number and a
16-bit local address. The two highest-order bits are set to 1-0. This
allows 16,384 class B networks.
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 0| NETWORK | Local Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Class B Address
The third type of address, class C, has a 21-bit network number and a
8-bit local address. The three highest-order bits are set to 1-1-0.
This allows 2,097,152 class C networks.
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1 0| NETWORK | Local Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Class C Address
The fourth type of address, class D, is used as a multicast address
[13]. The four highest-order bits are set to 1-1-1-0.
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1 1 0| multicast address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Class D Address
Note: No addresses are allowed with the four highest-order bits set to
1-1-1-1. These addresses, called "class E", are reserved.
Best Answer
I believe the book wrongly assumes network classes are still in effect. So a) would be a "Class A" network, where 10.255.255.255 would be the broadcast address. Another hint: There is no explicit network size specified (/24, /27, ..) so it is implied you know about network classes. Classical example of outdated literature.